Fix things in the docker spin-up script

This commit is contained in:
Salt 2021-06-20 20:25:47 -05:00
parent 273f4b2a23
commit 1d6192debf

View File

@ -20,6 +20,7 @@ if [ -n "$ANSIBLE_SSH_KEY" ]; then
mkdir /etc/sudoers.d
echo 'ansible ALL=(ALL:ALL) NOPASSWD:ALL' > /etc/sudoers.d/50-playbookuser
# And owns their home
mkdir -p /home/ansible
chown ansible. ~ansible
# Dump the private key as fast as possible to reduce leak
@ -31,7 +32,7 @@ if [ -n "$ANSIBLE_SSH_KEY" ]; then
chown ansible. ~ansible/.ssh/desu
# Give the ansible user a managable profile
cp /etc/ansible/roles/common/templates/profile.sh /etc/profile.d/50-ansible.sh
cp /etc/ansible.orig/roles/common/templates/profile.sh /etc/profile.d/50-ansible.sh
# Install the packages we need to test things in the repo
printf '\e[37mUpdating repositories...\e[0m\n'
@ -45,9 +46,10 @@ if [ -n "$ANSIBLE_SSH_KEY" ]; then
printf '\e[37mCreating local copy of playbook files...\e[0m\n'
mkdir /etc/ansible
chown ansible. /etc/ansible
sudo -u ansible rsync -aHS /etc/ansible.orig /etc/ansible --exclude .git
sudo -u ansible rsync -aHS /etc/ansible.orig/ /etc/ansible/ --exclude .git
printf '\e[37mInstalling roles...\e[0m\n'
sudo -u ansible ansible-galaxy install -r roles/requirements.yml -p roles
cd /etc/ansible
# Drop to the ansible user
printf '\e[32mAnsible is ready to run\e[0m\n'
@ -64,4 +66,4 @@ docker run -it \
-e "ANSIBLE_SSH_KEY=$ANSIBLE_SSH_KEY" \
-v "$PWD:/etc/ansible.orig:ro" \
ubuntu:focal \
bash -c 'cd /etc/ansible && ./contrib/docker.sh && exec bash'
bash -c 'cd /etc/ansible.orig && ./contrib/docker.sh'