ansible-taler-exchange

Ansible playbook to deploy a production Taler Exchange
Log | Files | Refs | README | LICENSE

main.yml (2359B)


      1 ---
      2 - name: Gather service facts for optional post-deployment checks
      3   ansible.builtin.service_facts:
      4 
      5 - name: Check that required systemd units are active
      6   ansible.builtin.command:
      7     argv:
      8       - systemctl
      9       - is-active
     10       - --quiet
     11       - "{{ item.unit }}"
     12   loop: "{{ post_deployment_systemd_checks }}"
     13   loop_control:
     14     label: "{{ item.unit }}"
     15   register: post_deployment_systemd_check
     16   changed_when: false
     17   check_mode: false
     18   failed_when: false
     19   retries: "{{ post_deployment_check_retries }}"
     20   delay: "{{ post_deployment_check_delay }}"
     21   until: post_deployment_systemd_check.rc == 0
     22   when: item.enabled | bool
     23 
     24 - name: Check that required HTTP endpoints respond
     25   ansible.builtin.uri:
     26     url: "{{ item.url }}"
     27     unix_socket: "{{ item.unix_socket | default(omit) }}"
     28     status_code: 200
     29     timeout: "{{ post_deployment_http_timeout }}"
     30     use_proxy: false
     31   loop: "{{ post_deployment_http_checks }}"
     32   loop_control:
     33     label: "{{ item.name }}"
     34   register: post_deployment_http_check
     35   changed_when: false
     36   check_mode: false
     37   failed_when: false
     38   retries: "{{ post_deployment_http_retries }}"
     39   delay: "{{ post_deployment_check_delay }}"
     40   until: post_deployment_http_check.status | default(-1) == 200
     41   when: item.enabled | bool
     42 
     43 - name: Collect failed post-deployment checks
     44   ansible.builtin.set_fact:
     45     post_deployment_failed_systemd_units: >-
     46       {{
     47         post_deployment_systemd_check.results
     48         | rejectattr('skipped', 'defined')
     49         | rejectattr('rc', 'equalto', 0)
     50         | map(attribute='item.unit')
     51         | list
     52       }}
     53     post_deployment_failed_http_endpoints: >-
     54       {{
     55         post_deployment_http_check.results
     56         | rejectattr('skipped', 'defined')
     57         | rejectattr('status', 'equalto', 200)
     58         | map(attribute='item.name')
     59         | list
     60       }}
     61 
     62 - name: Report post-deployment sanity check failures
     63   ansible.builtin.assert:
     64     that:
     65       - post_deployment_failed_systemd_units | length == 0
     66       - post_deployment_failed_http_endpoints | length == 0
     67     fail_msg: |-
     68       Post-deployment sanity checks failed.
     69       Inactive systemd units: {{ post_deployment_failed_systemd_units | join(', ') or 'none' }}
     70       Unavailable HTTP endpoints: {{ post_deployment_failed_http_endpoints | join(', ') or 'none' }}
     71     success_msg: All post-deployment sanity checks passed.