centos:ansible:detail

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
Nächste ÜberarbeitungBeide Seiten der Revision
centos:ansible:detail [11.01.2020 21:12. ] – [inventory - Beispiel] djangocentos:ansible:detail [11.01.2020 21:42. ] – [Script ausführen] django
Zeile 348: Zeile 348:
 Auch für die anderen Hosts legen wir entsprechende Dateien mit den Variablen an. Auch für die anderen Hosts legen wir entsprechende Dateien mit den Variablen an.
  
 +=== playbook ===
 +Die zuvor angelegte Inventory- und auch Host-/Group-Variablendateien wollen wir nun verwenden um die Geolocation-Daten unserer Freifunk-Knoten zu organisieren. Die Geodaten sind in den jeweiligen Host-Dateien in den beiden Variablen **''latitude''** und **''longitude''** gespeichert - diese beiden Variablen nutzen wir nun in unserem Playbook.
 +   $ ~/ansible/playbooks/09_set_location.yml
  
-FIXME Text ergänzen FIXME+<file bash ~/ansible/playbooks/09_set_location.yml> 
 +--- 
 +- hosts: ffmuc 
 +  gather_facts: False
  
-/*+  tasks: 
 +    - name: "Set GEO location of our own ffmuc-nodes" 
 +      #https://docs.ansible.com/ansible/latest/modules/raw_module.html 
 +      raw: uci set gluon-node-info.@location[0]="location"; uci set gluon-node-info.@location[0].share_location="1"; uci set gluon-node-info.@location[0].latitude="{{ latitude }}" ; uci set gluon-node-info.@location[0].longitude="{{ longitude }}"; uci commit gluon-node-info</file> 
 + 
 +=== Script antesten === 
 +Bevor wir nun das Playbook ausführen wollen wir erst einmal shen, ob auch die richtigen Hosts verwendet werden würden. Hierzu hat der Befehl **''ansible-playbook''** eine entsprechende Option **''--list-hosts''**. 
 +   $ ansible-playbook -v ~/ansible/playbooks/09_set_location.yml --list-hosts 
 + 
 +<html><pre class="code"> 
 +<font style="color: rgb(43, 100, 164)">Using /etc/ansible/ansible.cfg as config file</font> 
 + 
 +<font style="color: rgb(0, 0, 0)">playbook: /home/django/ansible/playbooks/09_set_location.yml 
 + 
 +  play #1 (ffmuc): ffmuc TAGS: [] 
 +    pattern: ['ffmuc'
 +    hosts (6): 
 +      ff_pliening_gbw_egod 
 +      ff_roding_as_nausch 
 +      ff_pliening_gbw_cpod 
 +      ff_pliening_gbw_dgod 
 +      ff_pliening_gbw_ogod 
 +      ff_pliening_gbw_ug</font></pre> 
 +</html> 
 + 
 +=== Script ausführen === 
 +Nun wollen wir unser ersten Playbook ausführen, um die Geodaten aus der Inventory-Datei auf unseren Freifunk-Knoten abzugleichen; hierzu rufen wir unser Script wie folgt auf: 
 +   $ ansible-playbook -v ~/ansible/playbooks/09_set_location.yml 
 + 
 +<html><pre class="code"> 
 +<font style="color: rgb(43, 100, 164)">Using /etc/ansible/ansible.cfg as config file</font> 
 +<font style="color: rgb(0, 0, 0)">BECOME password:  
 + 
 +PLAY [ffmuc] *************************************************************************************************************************** 
 + 
 +<font style="color: rgb(0, 0, 0)">TASK [Update new contact-address on own ffmuc-nodes] ***********************************************************************************</font> 
 +<font style="color: rgb(196, 160, 0)">changed: [ff_pliening_gbw_egod] => {"changed": true, "rc": 0, "stderr": "Shared connection to 2001:608:a01:102:1ae8:29ff:fea9:22ed closed.\r\n", "stderr_lines": ["Shared connection to 2001:608:a01:102:1ae8:29ff:fea9:22ed closed."], "stdout": "", "stdout_lines": []} 
 +changed: [ff_pliening_gbw_kvm_ol] => {"changed": true, "rc": 0, "stderr": "Shared connection to 2001:608:a01:102:5054:ff:fe9e:b358 closed.\r\n", "stderr_lines": ["Shared connection to 2001:608:a01:102:5054:ff:fe9e:b358 closed."], "stdout": "", "stdout_lines": []} 
 +changed: [ff_pliening_gbw_ogod] => {"changed": true, "rc": 0, "stderr": "Shared connection to 2001:608:a01:102:1ae8:29ff:fec0:aaae closed.\r\n", "stderr_lines": ["Shared connection to 2001:608:a01:102:1ae8:29ff:fec0:aaae closed."], "stdout": "", "stdout_lines": []} 
 +changed: [ff_pliening_gbw_ug] => {"changed": true, "rc": 0, "stderr": "Shared connection to 2001:608:a01:102:32b5:c2ff:fe56:62b1 closed.\r\n", "stderr_lines": ["Shared connection to 2001:608:a01:102:32b5:c2ff:fe56:62b1 closed."], "stdout": "", "stdout_lines": []} 
 +changed: [ff_pliening_gbw_dgod] => {"changed": true, "rc": 0, "stderr": "Shared connection to 2001:608:a01:102:1ae8:29ff:fec6:c8eb closed.\r\n", "stderr_lines": ["Shared connection to 2001:608:a01:102:1ae8:29ff:fec6:c8eb closed."], "stdout": "", "stdout_lines": []} 
 +changed: [ff_pliening_gbw_cpod] => {"changed": true, "rc": 0, "stderr": "Shared connection to 2001:608:a01:102:1ae8:29ff:fec6:c8dd closed.\r\n", "stderr_lines": ["Shared connection to 2001:608:a01:102:1ae8:29ff:fec6:c8dd closed."], "stdout": "", "stdout_lines": []}</font><br> 
 +<font style="color: rgb(0, 0, 0)">PLAY RECAP *****************************************************************************************************************************</font> 
 +<font style="color: rgb(196, 160, 0)">ff_pliening_gbw_cpod       </font><font style="color: rgb(0, 0, 0)">: </font><font style="color: rgb(25, 100, 5)">ok=1    </font><font style="color: rgb(196, 160, 0)">changed=1    </font><font style="color: rgb(0, 0, 0)">unreachable=0    failed=0    skipped=0    rescued=0    ignored=0</font> 
 +<font style="color: rgb(196, 160, 0)">ff_pliening_gbw_dgod       </font><font style="color: rgb(0, 0, 0)">: </font><font style="color: rgb(25, 100, 5)">ok=1    </font><font style="color: rgb(196, 160, 0)">changed=1    </font><font style="color: rgb(0, 0, 0)">unreachable=0    failed=0    skipped=0    rescued=0    ignored=0</font> 
 +<font style="color: rgb(196, 160, 0)">ff_pliening_gbw_egod       </font><font style="color: rgb(0, 0, 0)">: </font><font style="color: rgb(25, 100, 5)">ok=1    </font><font style="color: rgb(196, 160, 0)">changed=1    </font><font style="color: rgb(0, 0, 0)">unreachable=0    failed=0    skipped=0    rescued=0    ignored=0</font> 
 +<font style="color: rgb(196, 160, 0)">ff_pliening_gbw_kvm_ol     </font><font style="color: rgb(0, 0, 0)">: </font><font style="color: rgb(25, 100, 5)">ok=1    </font><font style="color: rgb(196, 160, 0)">changed=1    </font><font style="color: rgb(0, 0, 0)">unreachable=0    failed=0    skipped=0    rescued=0    ignored=0</font> 
 +<font style="color: rgb(196, 160, 0)">ff_pliening_gbw_ogod       </font><font style="color: rgb(0, 0, 0)">: </font><font style="color: rgb(25, 100, 5)">ok=1    </font><font style="color: rgb(196, 160, 0)">changed=1    </font><font style="color: rgb(0, 0, 0)">unreachable=0    failed=0    skipped=0    rescued=0    ignored=0</font> 
 +<font style="color: rgb(196, 160, 0)">ff_pliening_gbw_ug         </font><font style="color: rgb(0, 0, 0)">: </font><font style="color: rgb(25, 100, 5)">ok=1    </font><font style="color: rgb(196, 160, 0)">changed=1    </font><font style="color: rgb(0, 0, 0)">unreachable=0    failed=0    skipped=0    rescued=0    ignored=0</font> 
 +<br></pre> 
 +</html> 
 + 
 +=== Ergebnis === 
 +Nun haben alle unsere eigenen definierten Freifunk Knoten haben nun auf der **[[https://map.ffmuc.net/#!/de/map/18e829a922ed|Freifunk München Karte]]*die aktualisierten GeoDaten. Zum anderen ist der Administrative Aufwand entsprechend überschaubar. 
 + 
 +Zum Thema administrativer Aufwand wollen wir uns kurz noch ein kleines Rechenbeispiel ansehen. Nehmen wir mal an, wie hätten eine etwas größere Installation mit folgenden Eckdaten:
   * **145** Zeilen (ohne Variablen):   * **145** Zeilen (ohne Variablen):
     * mit **76** Hosts     * mit **76** Hosts
Zeile 362: Zeile 423:
 ergäbe dies eine Inventory-Datei mit **__1.350__** Zeilen. 8-o ergäbe dies eine Inventory-Datei mit **__1.350__** Zeilen. 8-o
  
-*/ 
  
 /* /*
Zeile 377: Zeile 437:
  
 /* https://gerardnico.com/infra/ansible/start */ /* https://gerardnico.com/infra/ansible/start */
 +