Browse Source

Upload files to ''

master
alex_kikis 4 years ago
parent
commit
be500a8b96
  1. 50
      mongodb-org-shell.yml.sh

50
mongodb-org-shell.yml.sh

@ -0,0 +1,50 @@
#!/bin/sh
sudo apt update -y
sudo apt install -y ansible sshpass
sudo mkdir -p /home/docker/.ansible
sudo chown docker.docker -R /home/docker
sudo cp files/ansible.cfg /etc/ansible/ansible.cfg
ip4=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)
ip6=$(/sbin/ip -o -6 addr list eth0 | awk '{print $4}' | cut -d/ -f1)
YAML=mongodb-org-shell
echo "[service]" > /project/courses/$YAML/inventory.yml
/project/bin/swarmlab-nmap >> /project/courses/$YAML/inventory.yml
# include master or not
echo $ip4 >> /project/courses/$YAML/inventory.yml
VAR=$(cat <<'END_HEREDOC'
sudo rm -f /etc/apt/sources.list.d/repo_mongodb_org_apt_ubuntu.list
sudo rm -f /etc/apt/sources.list.d/mongodb*.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 656408E390CFB1F5
echo "deb [arch=amd64] http://repo.mongodb.org/apt/ubuntu $(lsb_release -sc)/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org.list
END_HEREDOC
)
echo ""
echo "These comands will be executed first on the remote servers."
echo "They are located under the files/mongo-update.sh file."
echo ""
echo "$VAR"
echo ""
read -p "Continue (y/n)?" CONT
if [ "$CONT" = "y" ]; then
ansible-playbook -u docker -i inventory.yml $YAML.yml -f 5 --ask-pass --ask-become-pass
else
echo " ";
fi
# 1st make sudo without password
# run with keys
#ansible-playbook -u docker -i inventory.yml $YAML.yml -f 5 --private-key=/home/docker/.ssh/id_rsa
Loading…
Cancel
Save