From 32f25bb46d048b3d8e03500c8a7c32c5b94b2d20 Mon Sep 17 00:00:00 2001 From: lefos Date: Sun, 31 Oct 2021 21:40:47 +0200 Subject: [PATCH] asd --- inventory.yml | 2 ++ monitorall.yml | 64 +++++++++++++++++++++++------------------------ monitorall.yml.sh | 7 +++++- 3 files changed, 40 insertions(+), 33 deletions(-) diff --git a/inventory.yml b/inventory.yml index e69de29..8b9915a 100644 --- a/inventory.yml +++ b/inventory.yml @@ -0,0 +1,2 @@ +[service] +172.25.0.3 \ No newline at end of file diff --git a/monitorall.yml b/monitorall.yml index 260f99f..fca4de2 100644 --- a/monitorall.yml +++ b/monitorall.yml @@ -1,5 +1,5 @@ --- -- hosts: services +--- +- hosts: service remote_user: docker gather_facts: no vars: @@ -10,37 +10,37 @@ # ------------------------ # apt update # ------------------------- - - name: apt update packages - become: true - apt: - update_cache: 'yes' - force_apt_get: 'yes' - upgrade: 'dist' - cache_valid_time: 3600 - install_recommends: true - autoremove: true + - name: apt update packages + become: true + apt: + update_cache: 'yes' + force_apt_get: 'yes' + upgrade: 'dist' + cache_valid_time: 3600 + install_recommends: true + autoremove: true # ------------------------ # apt install packages # ------------------------- - - name: apt install packages - become: true - apt: - update_cache: 'yes' - force_apt_get: 'yes' - install_recommends: true - autoremove: true - name: "{{ packages }}" - vars: - packages: - - build-essential - - name: Import the public key used by the package management system - apt_key: keyserver=hkp://keyserver.ubuntu.com:80 id=7F0CEB10 state=present - - name: Add MongoDB repository - apt_repository: repo='deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' state=present - - name: install mongodb - apt: pkg=mongodb-org state=latest update_cache=yes - notify: - - start mongodb - handlers: - - name: start mongodb + - name: apt install packages + become: true + apt: + update_cache: 'yes' + force_apt_get: 'yes' + install_recommends: true + autoremove: true + name: "{{ packages }}" + vars: + packages: + - build-essential + - name: Import the public key used by the package management system + apt_key: keyserver=hkp://keyserver.ubuntu.com:80 id=7F0CEB10 state=present + - name: Add MongoDB repository + apt_repository: repo='deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' state=present + - name: install mongodb + apt: pkg=mongodb-org state=latest update_cache=yes + notify: + - start mongodb + handlers: + - name: start mongodb service: name=mongod state=started \ No newline at end of file diff --git a/monitorall.yml.sh b/monitorall.yml.sh index f015e69..b137483 100644 --- a/monitorall.yml.sh +++ b/monitorall.yml.sh @@ -8,9 +8,11 @@ sudo chown docker.docker -R /home/docker sudo cp files/ansible.cfg /etc/ansible/ansible.cfg +#master ip 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) +#workers ip echo "[service]" > /project/courses/Thesis/inventory.yml /project/bin/swarmlab-nmap >> /project/courses/Thesis/inventory.yml @@ -21,4 +23,7 @@ echo $ip4 >> /project/courses/Thesis/inventory.yml ansible-playbook -u docker -i inventory.yml monitorall.yml -f 5 --ask-pass --ask-become-pass # 1st make sudo without password # run with keys -#ansible-playbook -u docker -i inventory.yml fluentd.yml -f 5 --private-key=/home/docker/.ssh/id_rsa \ No newline at end of file +#ansible-playbook -u docker -i inventory.yml fluentd.yml -f 5 --private-key=/home/docker/.ssh/id_rsa + +#get workers ip +#nmap -sn -oG - $ip/24 | grep Up | grep $NODENETWORK | cut -d ' ' -f 2 \ No newline at end of file