delegate delete tasks locally

This commit is contained in:
Michael Collins 2021-08-20 09:35:12 +08:00
parent 312bcc444b
commit 14effd5e2b
4 changed files with 40 additions and 2 deletions

View File

@ -13,6 +13,7 @@
no_log: True no_log: True
- name: Remove original 'Provision Server' job template - name: Remove original 'Provision Server' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "0 - {{ subscription_id }} - Provision a New Server" name: "0 - {{ subscription_id }} - Provision a New Server"
job_type: run job_type: run
@ -24,6 +25,7 @@
validate_certs: yes validate_certs: yes
- name: Remove 'Provision Wireguard Server' job template - name: Remove 'Provision Wireguard Server' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "0 - {{ subscription_id }} - Provision Wireguard Server" name: "0 - {{ subscription_id }} - Provision Wireguard Server"
job_type: run job_type: run
@ -35,6 +37,7 @@
validate_certs: yes validate_certs: yes
- name: Remove schedule for 'Deploy a New Server' job template - name: Remove schedule for 'Deploy a New Server' job template
delegate_to: 127.0.0.1
awx.awx.tower_schedule: awx.awx.tower_schedule:
name: "{{ matrix_domain }} - 0 - Update Server Schedule" name: "{{ matrix_domain }} - 0 - Update Server Schedule"
enabled: yes enabled: yes
@ -45,6 +48,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Backup Server' job template - name: Remove 'Backup Server' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 0 - Backup Server" name: "{{ matrix_domain }} - 0 - Backup Server"
job_type: run job_type: run
@ -57,6 +61,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Export Server' job template - name: Remove 'Export Server' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 0 - Export Server" name: "{{ matrix_domain }} - 0 - Export Server"
job_type: run job_type: run
@ -69,6 +74,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Deploy/Update a Server' job template - name: Remove 'Deploy/Update a Server' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 0 - Deploy/Update a Server" name: "{{ matrix_domain }} - 0 - Deploy/Update a Server"
job_type: run job_type: run
@ -81,6 +87,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Self-Check' job template - name: Remove 'Self-Check' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 0 - Self-Check" name: "{{ matrix_domain }} - 0 - Self-Check"
job_type: run job_type: run
@ -93,6 +100,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Start/Restart all Services' job template - name: Remove 'Start/Restart all Services' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 0 - Start/Restart all Services" name: "{{ matrix_domain }} - 0 - Start/Restart all Services"
job_type: run job_type: run
@ -105,6 +113,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Stop all Services' job template - name: Remove 'Stop all Services' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 0 - Stop all Services" name: "{{ matrix_domain }} - 0 - Stop all Services"
job_type: run job_type: run
@ -117,6 +126,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Configure Corporal (Advanced)' job template - name: Remove 'Configure Corporal (Advanced)' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 1 - Configure Corporal (Advanced)" name: "{{ matrix_domain }} - 1 - Configure Corporal (Advanced)"
job_type: run job_type: run
@ -129,6 +139,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Configure Dimension' job template - name: Remove 'Configure Dimension' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 1 - Configure Dimension" name: "{{ matrix_domain }} - 1 - Configure Dimension"
job_type: run job_type: run
@ -141,6 +152,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Configure Element' job template - name: Remove 'Configure Element' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 1 - Configure Element" name: "{{ matrix_domain }} - 1 - Configure Element"
job_type: run job_type: run
@ -153,6 +165,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Configure Element Subdomain' job template - name: Remove 'Configure Element Subdomain' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 1 - Configure Element Subdomain" name: "{{ matrix_domain }} - 1 - Configure Element Subdomain"
job_type: run job_type: run
@ -165,6 +178,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Configure Email Relay' job template - name: Remove 'Configure Email Relay' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 1 - Configure Email Relay" name: "{{ matrix_domain }} - 1 - Configure Email Relay"
job_type: run job_type: run
@ -177,6 +191,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Configure Jitsi' job template - name: Remove 'Configure Jitsi' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 1 - Configure Jitsi" name: "{{ matrix_domain }} - 1 - Configure Jitsi"
job_type: run job_type: run
@ -189,6 +204,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Configure ma1sd (Advanced)' job template - name: Remove 'Configure ma1sd (Advanced)' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 1 - Configure ma1sd (Advanced)" name: "{{ matrix_domain }} - 1 - Configure ma1sd (Advanced)"
job_type: run job_type: run
@ -201,6 +217,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Configure Synapse' job template - name: Remove 'Configure Synapse' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 1 - Configure Synapse" name: "{{ matrix_domain }} - 1 - Configure Synapse"
job_type: run job_type: run
@ -213,6 +230,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Configure Synapse Admin' job template - name: Remove 'Configure Synapse Admin' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 1 - Configure Synapse Admin" name: "{{ matrix_domain }} - 1 - Configure Synapse Admin"
job_type: run job_type: run
@ -225,6 +243,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Access Export' job template - name: Remove 'Access Export' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 1 - Access Export" name: "{{ matrix_domain }} - 1 - Access Export"
job_type: run job_type: run
@ -237,6 +256,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Configure Website + Access Export' job template - name: Remove 'Configure Website + Access Export' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 1 - Configure Website + Access Export" name: "{{ matrix_domain }} - 1 - Configure Website + Access Export"
job_type: run job_type: run
@ -249,6 +269,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Create User' job template - name: Remove 'Create User' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 2 - Create User" name: "{{ matrix_domain }} - 2 - Create User"
job_type: run job_type: run
@ -261,6 +282,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove 'Purge Media (Advanced)' job template - name: Remove 'Purge Media (Advanced)' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "{{ matrix_domain }} - 2 - Purge Media (Advanced)" name: "{{ matrix_domain }} - 2 - Purge Media (Advanced)"
job_type: run job_type: run
@ -273,6 +295,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove '<< SUBSCRIPTION DELETION IN PROGRESS >>' job template - name: Remove '<< SUBSCRIPTION DELETION IN PROGRESS >>' job template
delegate_to: 127.0.0.1
awx.awx.tower_job_template: awx.awx.tower_job_template:
name: "0 - {{ subscription_id }} - << SUBSCRIPTION DELETION IN PROGRESS >>" name: "0 - {{ subscription_id }} - << SUBSCRIPTION DELETION IN PROGRESS >>"
job_type: run job_type: run
@ -284,6 +307,7 @@
validate_certs: yes validate_certs: yes
- name: Remove Matrix server from organisations inventory - name: Remove Matrix server from organisations inventory
delegate_to: 127.0.0.1
awx.awx.tower_host: awx.awx.tower_host:
name: "matrix.{{ matrix_domain }}" name: "matrix.{{ matrix_domain }}"
description: "{{ matrix_domain }} Matrix Server" description: "{{ matrix_domain }} Matrix Server"
@ -295,6 +319,7 @@
when: matrix_domain is defined when: matrix_domain is defined
- name: Remove Wireguard Server from organisations inventory - name: Remove Wireguard Server from organisations inventory
delegate_to: 127.0.0.1
awx.awx.tower_host: awx.awx.tower_host:
name: "wireguard.{{ matrix_domain }}" name: "wireguard.{{ matrix_domain }}"
description: "{{ matrix_domain }} Wireguard Proxy" description: "{{ matrix_domain }} Wireguard Proxy"

View File

@ -1,5 +1,6 @@
- name: Include matrix server variables from matrix_vars.yml - name: Include matrix server variables from matrix_vars.yml
delegate_to: 127.0.0.1
include_vars: "{{ item }}" include_vars: "{{ item }}"
with_first_found: with_first_found:
- files: - files:
@ -7,8 +8,15 @@
skip: true skip: true
no_log: True no_log: True
- name: Install curl in AWX
delegate_to: 127.0.0.1
yum:
name: curl
state: latest
- name: Delete MailGun SMTP login - name: Delete MailGun SMTP login
delegate_to: 127.0.0.1
shell: | shell: |
curl -s --user 'api:{{ mg_private_api_key }}' -X DELETE https://{{ mg_api_url }}/v3/domains/{{ mg_sender_domain }}/credentials/{{ matrix_domain }} curl -s --user 'api:{{ mg_private_api_key }}' -X DELETE https://{{ mg_api_url }}/v3/domains/{{ mg_sender_domain }}/credentials/{{ matrix_domain }}
when: matrix_domain is defined when: matrix_domain is defined
# no_log: True no_log: True

View File

@ -1,20 +1,24 @@
- name: Include hosting vars of digital_ocean.yml - name: Include hosting vars of digital_ocean.yml
delegate_to: 127.0.0.1
include_vars: include_vars:
file: /var/lib/awx/projects/hosting/hosting_vars.yml file: /var/lib/awx/projects/hosting/hosting_vars.yml
no_log: True no_log: True
- name: Load vars from organisation.yml - name: Load vars from organisation.yml
delegate_to: 127.0.0.1
include_vars: include_vars:
file: '/var/lib/awx/projects/clients/{{ member_id }}/organisation.yml' file: '/var/lib/awx/projects/clients/{{ member_id }}/organisation.yml'
- name: Load vars from server_vars.yml - name: Load vars from server_vars.yml
delegate_to: 127.0.0.1
include_vars: include_vars:
file: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/server_vars.yml' file: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/server_vars.yml'
ignore_errors: yes ignore_errors: yes
- name: Remove existing Digital Ocean Droplet - name: Remove existing Digital Ocean Droplet
delegate_to: 127.0.0.1
community.digitalocean.digital_ocean_droplet: community.digitalocean.digital_ocean_droplet:
# needs ansible 2.8+ (AWX uses 2.9.10 at ) # needs ansible 2.8+ (AWX uses 2.9.10 at )
state: absent state: absent

View File

@ -1,5 +1,6 @@
- name: Delete the servers directory on AWX - name: Delete the servers directory on AWX
delegate_to: 127.0.0.1
file: file:
path: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/' path: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/'
state: absent state: absent