From be500a8b967ea38e990abb3f906573e03287f316 Mon Sep 17 00:00:00 2001 From: alex_kikis Date: Sat, 12 Jun 2021 14:39:37 +0000 Subject: [PATCH] Upload files to '' --- mongodb-org-shell.yml.sh | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 mongodb-org-shell.yml.sh diff --git a/mongodb-org-shell.yml.sh b/mongodb-org-shell.yml.sh new file mode 100644 index 0000000..030f203 --- /dev/null +++ b/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