diff --git a/CloudComputing_Lab/modules/ROOT/pages/ansible.adoc b/CloudComputing_Lab/modules/ROOT/pages/ansible.adoc index 69a7724..d8ec7db 100755 --- a/CloudComputing_Lab/modules/ROOT/pages/ansible.adoc +++ b/CloudComputing_Lab/modules/ROOT/pages/ansible.adoc @@ -1,6 +1,9 @@ = CaaS - OS Admin + + + == Playbook [source,sh] @@ -211,6 +214,42 @@ == Playbook files +== inventory file (Stattic) + +[source,sh] +---- +[service] +172.31.0.3 +172.31.0.4 +172.31.0.5 +172.31.0.6 +172.31.0.2 +---- + +== inventory file (Auto) + +[source,sh] +---- +#!/bin/sh + +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) + +ip=`nslookup $NODENAME | grep Addr | cut -d':' -f2 | grep -v 127.0.` +echo "[service]" > ./inventory.yml +nmap -sn -oG - $ip/24 | grep Up | grep $NODENETWORK | cut -d ' ' -f 2 >> ./inventory.yml + +# include ansible host or not +#echo $ip4 >> ./inventory.yml + + +---- + + + + + + === fluentd conf file [source,sh] @@ -785,3 +824,14 @@ host_key_checking = False # Set how many context lines to show in diff # context = 3 ---- + +== Run it! + +[source,sh] +---- +#!/bin/sh + +ansible-playbook -u docker -i inventory.yml file.yml -f 5 --ask-pass --ask-become-pass +# run with keys +#ansible-playbook -u docker -i inventory.yml fluentd.yml -f 5 --private-key=/home/docker/.ssh/id_rsa +----