pixel
Seite wählen

Ansible – AWX|Tower State handling on Workflows

von | Apr 27, 2021 | NETWAYS, Icinga, Python, Ansible

The Ansible Tower or its upstream AWX provides an easy to use GUI to handle Ansible tasks and schedules. Playbooks are configured as templates and as the name suggests, they can be modified to the needs, extended by variables, a survey or tags.

Furthermore those templates can be logically grouped, connected and visualised in Workflows.

The downside to those Workflows, all playbooks affected by this are executed separately and can’t access each others variables. On first glance we maybe only spot that we can define variables for the whole workflow but those are not changeable throughout the flow.

But there is a solution, which is the module set_stats. This module allows to save or accumulate variables and make them available for other playbooks within the workflow.

As an example we could use the monitoring environment when setting downtimes.

workflow

As a downtime is created before a maintenance and should be gone when the maintenance is done. This creates a dependency on the first task, which can be solved as we save the result of the first tasks with the set_stats module.


      - name: schedule downtimes
        icinga2_downtimes:
          state: "{{ downtime_icinga_state | default('present') }}"
          host: ***
          author: "{{ icinga2_downtimes_author | default('ansible_downtime') }}"
          comment: "{{ icinga2_downtimes_comment | default('Downtime scheduled by Ansible') }}"
          duration: "{{ icinga2_downtimes_duration | default(omit) }}"
        register: content
 
      - set_stats:
          data:
            downtime: "{{ content }}"

The content of the data will be now available to all playbooks included by the workflow. The variable is also shown as artefacts in the GUI.

artefacts

Keep in mind that the variable will be part of the extra variables for all other playbooks. As covered in the variable precedence it will overwrite any other variable named the same.

With this module you can reorganise your playbooks and connect them in workflows. This allows you to have a more flexible automation than before.

Check out our Blog for more awesome posts and if you need help with Ansible send us a message or sign up for one of our trainings!

Thilo Wening
Thilo Wening
Manager Consulting

Thilo hat bei NETWAYS mit der Ausbildung zum Fachinformatiker, Schwerpunkt Systemadministration begonnen und unterstützt nun nach erfolgreich bestandener Prüfung tatkräftig die Kollegen im Consulting. In seiner Freizeit ist er athletisch in der Senkrechten unterwegs und stählt seine Muskeln beim Bouldern. Als richtiger Profi macht er das natürlich am liebsten in der Natur und geht nur noch in Ausnahmefällen in die Kletterhalle.

0 Kommentare

Einen Kommentar abschicken

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Mehr Beiträge zum Thema NETWAYS | Icinga | Python | Ansible

Monthly Snap September 2023

Hallo zusammen! September war bei NETWAYS natürlich vor Allem der Monat der stackconf! Alle die für den Anlass nach Berlin „gepilgert“ sind waren sich einig, dass es eine grandiose Konferenz war, die viel zu schnell zu Ende ging!   Stackconf! Hier könnt ihr über...

Why We’re Excited About DevOps Camp 2023!

This year, our NETWAYS Web Services Team is highly motivated to participate in DevOps Camp in Nuremberg! After a short break since stackconf in Berlin, we are back at a conference. We are delighted to be able to support DevOps Camp once again. In this article, we...

Finance and Administrations on Tour!

Lange haben wir uns darauf gefreut, und am Wochenende war es dann endlich so weit: F&A ist endlich zum Teamevent aufgebrochen! Wir sind in die wunderschöne Stadt Würzburg gefahren, und haben dort unter anderem eine geführte Weinwanderung genossen!   Aber...

check_influxdb ist jetzt öffentlich verfügbar!

InfluxDB ist eine Zeitreihendatenbank, die gerne für Performance Monitoring genutzt wird. Zusammen mit dem Telegraf Agenten, kann man so ziemlich alle vorstellbaren Formate einliefern und diese in Metriken oder Logs transformieren. Hat man die Daten einmal in der...