Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

51 lines
2.2 KiB

  1. - name: Record Mailer variables locally on AWX
  2. delegate_to: 127.0.0.1
  3. lineinfile:
  4. path: '{{ awx_cached_matrix_vars }}'
  5. regexp: "^#? *{{ item.key | regex_escape() }}:"
  6. line: "{{ item.key }}: {{ item.value }}"
  7. insertafter: '# Email Settings Start'
  8. with_dict:
  9. 'matrix_mailer_relay_use': '{{ matrix_mailer_relay_use }}'
  10. - name: Save new 'Configure Email Relay' survey.json to the AWX tower, template
  11. delegate_to: 127.0.0.1
  12. template:
  13. src: 'roles/matrix-awx/surveys/configure_email_relay.json.j2'
  14. dest: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_email_relay.json'
  15. - name: Copy new 'Configure Email Relay' survey.json to target machine
  16. copy:
  17. src: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_email_relay.json'
  18. dest: '/matrix/awx/configure_email_relay.json'
  19. mode: '0660'
  20. - name: Collect AWX admin token the hard way!
  21. delegate_to: 127.0.0.1
  22. shell: |
  23. curl -sku {{ tower_username }}:{{ tower_password }} -H "Content-Type: application/json" -X POST -d '{"description":"Tower CLI", "application":null, "scope":"write"}' https://{{ tower_host }}/api/v2/users/1/personal_tokens/ | jq '.token' | sed -r 's/\"//g'
  24. register: tower_token
  25. no_log: True
  26. - name: Recreate 'Configure Email Relay' job template
  27. delegate_to: 127.0.0.1
  28. awx.awx.tower_job_template:
  29. name: "{{ matrix_domain }} - 1 - Configure Email Relay"
  30. description: "Enable MailGun relay to increase verification email reliability."
  31. extra_vars: "{{ lookup('file', '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/extra_vars.json') }}"
  32. job_type: run
  33. job_tags: "start,setup-mailer"
  34. inventory: "{{ member_id }}"
  35. project: "{{ member_id }} - Matrix Docker Ansible Deploy"
  36. playbook: setup.yml
  37. credential: "{{ member_id }} - AWX SSH Key"
  38. survey_enabled: true
  39. survey_spec: "{{ lookup('file', '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_email_relay.json') }}"
  40. become_enabled: yes
  41. state: present
  42. verbosity: 1
  43. tower_host: "https://{{ tower_host }}"
  44. tower_oauthtoken: "{{ tower_token.stdout }}"
  45. validate_certs: yes