Skip to content

Commit 71423d8

Browse files
committed
venv approach
1 parent e37c868 commit 71423d8

File tree

1 file changed

+17
-66
lines changed
  • lib/allora/lib/assets/user-data

1 file changed

+17
-66
lines changed

lib/allora/lib/assets/user-data/node.sh

Lines changed: 17 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@ echo "RESOURCE_ID=${_NODE_CF_LOGICAL_ID_}" >> /etc/environment
99
echo "STACK_NAME=${_STACK_NAME_}" >> /etc/environment
1010
echo "STACK_ID=${_STACK_ID_}" >> /etc/environment
1111

12+
source /etc/environment
13+
1214
#############################
1315
# Prerequisites
14-
# Aws cli (for signalling)
1516
# Pip
1617
# Pipx
17-
# docker.io
18-
# Docker compose
1918
# Go
2019
#############################
2120

21+
22+
23+
2224
# Update Ubuntu, answer yes to all prompts non-interactively
2325
echo "[user-data] Update Ubuntu package list"
26+
sudo add-apt-repository ppa:deadsnakes/ppa
2427
sudo apt-get update --yes
2528

2629

2730
# Install pip
28-
echo "[user-data] Install Python, Pip, and Venv"
29-
sudo add-apt-repository ppa:deadsnakes/ppa --yes
30-
sudo apt-get update --yes
31-
sudo apt install python3.7 --yes
32-
sudo apt-get install -y python3-pip python3-venv
31+
echo "[user-data] Pip"
32+
sudo apt-get install -y python3-pip
3333

3434

3535
# Install Pipx
@@ -41,7 +41,6 @@ pipx ensurepath
4141
echo "[user-data] Install Go"
4242
sudo apt-get install golang-go --yes
4343

44-
# Install Docker Compose
4544
# Install ca-certificates, a certificate authority package for verifying third-party identities, and curl, a data transfer tool:
4645
echo "[user-data] Install ca-certificates"
4746
sudo apt-get install ca-certificates --yes
@@ -61,68 +60,20 @@ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyring
6160
echo "[user-data] set read permissions for key"
6261
sudo chmod a+r /etc/apt/keyrings/docker.asc
6362

63+
# install cfn
6464

65-
# Add the Docker repository to the list of APT sources:
66-
echo \
67-
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
68-
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
69-
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
70-
71-
# update again since we added the docker repo to apt sources
72-
echo "[user-data] Update again after adding docker repo to apt sources"
73-
sudo apt-get update --yes
74-
75-
# Install Docker Compose:
76-
echo "[user-data] Install docker compose"
77-
sudo apt-get install docker-compose-plugin --yes
78-
79-
# Install Docker.io
80-
echo "[user-data] Install docker.io"
81-
sudo apt-get install docker.io --yes
82-
83-
# After the download completes, confirm that Docker Compose is installed by typing:
84-
echo "[user-data] run docker compose version"
85-
docker compose version
86-
87-
echo "[user-data] docker group and usermod"
88-
# Create the docker group if it does not already exist:
89-
sudo groupadd -f docker
90-
# Add the current user to the docker group via the usermod command:
91-
sudo usermod -aG docker $USER
92-
93-
# Start docker service
94-
echo "[user-data] Starting docker service"
95-
sudo service docker start
96-
97-
echo "[user-data] Signaling completion to CloudFormation"
98-
if [[ "$STACK_ID" != "none" ]]; then
99-
echo "Install and enable CloudFormation helper scripts"
100-
mkdir -p /opt/aws/
101-
pip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
102-
sudo ln -s /usr/local/init/ubuntu/cfn-hup /etc/init.d/cfn-hup
103-
104-
echo "Configuring CloudFormation helper scripts"
105-
mkdir -p /etc/cfn/
106-
mv /opt/cfn-hup/cfn-hup.conf /etc/cfn/cfn-hup.conf
107-
sed -i "s;__AWS_STACK_ID__;\"$STACK_ID\";g" /etc/cfn/cfn-hup.conf
108-
sed -i "s;__AWS_REGION__;\"$AWS_REGION\";g" /etc/cfn/cfn-hup.conf
109-
110-
mkdir -p /etc/cfn/hooks.d/
111-
mv /opt/cfn-hup/cfn-auto-reloader.conf /etc/cfn/hooks.d/cfn-auto-reloader.conf
112-
sed -i "s;__AWS_STACK_NAME__;\"$STACK_NAME\";g" /etc/cfn/hooks.d/cfn-auto-reloader.conf
113-
sed -i "s;__AWS_REGION__;\"$AWS_REGION\";g" /etc/cfn/hooks.d/cfn-auto-reloader.conf
114-
115-
echo "Starting CloudFormation helper scripts as a service"
116-
mv /opt/cfn-hup/cfn-hup.service /etc/systemd/system/cfn-hup.service
65+
# install python 3.11
66+
sudo apt-get install python3.11 --yes
11767

118-
systemctl daemon-reload
119-
systemctl enable --now cfn-hup
120-
systemctl start cfn-hup.service
68+
sudo apt-get install python3.11-venv
69+
sudo python3.11 -m venv env
70+
source env/bin/activate
12171

122-
cfn-signal --stack $STACK_NAME --resource $RESOURCE_ID --region $AWS_REGION
123-
fi
72+
sudo apt-get install heat-cfntools --yes
12473

74+
cfn-init --stack $STACK_NAME --resource $RESOURCE_ID --region $AWS_REGION --configsets setup
12575

76+
cfn-signal -e $? --stack $STACK_NAME --resource $RESOURCE_ID --region $AWS_REGION
12677

12778
echo "----------------------------------------------"
12879
echo "[user-data] Allora user-data script successful"

0 commit comments

Comments
 (0)