Questions/howto: AWX version updates

I don’t have answers for all your questions, but for #3 in your list, you can use the awx.awx.export module in a playbook to export the settings of your current AWX installation.

Save the export results to a file. The file will contain all of your settings, but sensitive settings will have placeholders instead of your actual values.

For example, your credentials will look like this in the export file.

- credential_type: {kind: cloud, name: A10, type: credential_type}
  description: Development A10 Credentials
  inputs: {a10_password: $encrypted$, a10_username: MyA10User}
  name: A10 Dev
  natural_key:
    credential_type: {kind: cloud, name: A10, type: credential_type}
    name: A10 Dev
    organization: {name: MyOrg, type: organization}
    type: credential
  organization: {name: MyOrg, type: organization}

Notice the $encrypted$ value. You will have to go through the export file and replace those placeholders with the real values.

Then, you can use the awx.awx.import module to send those settings to the new installation. I have never done this to send an entire configuration from one instance to another, but I have used it to send parts of the configuration from one instance to another.

Sample playbook to export all settings into their own yaml files:

- name:  ========== Export AWX Settings ==========
  connection: local
  hosts: lab
  gather_facts: no
  environment:
    CONTROLLER_USERNAME: "{{ vault_controller_username }}"
    CONTROLLER_PASSWORD: "{{ vault_controller_password }}"
    CONTROLLER_HOST: "{{ awx_url }}"

  tasks:
    - name: Export All Settings
      awx.awx.export:
        all: True
      register: assets

    - name: SAVE EXPORT TO YML FILE
      delegate_to: localhost
      copy:
        dest: "exports/backup.yml"
        content: "{{ assets.assets | to_yaml }}"

    - name: SAVE JOB_TEMPLATES TO YML FILE
      delegate_to: localhost
      copy:
        dest: "exports/backup_{{ item.key }}.yml"
        content: "{{ { item.key : item.value } | to_yaml }}"
      with_items: "{{ assets.assets | dict2items }}"

Sample playbook to import all settings from backup files in the exports directory:

- name:  ========== Import All AWX Settings ==========
  connection: local
  hosts: lab
  gather_facts: no
  environment:
    CONTROLLER_USERNAME: "{{ vault_controller_username }}"
    CONTROLLER_PASSWORD: "{{ vault_controller_password }}"
    CONTROLLER_HOST: "{{ awx_url }}"

  tasks:
    - name: IMPORT SETTINGS FROM EXPORTS
      awx.awx.import:
        assets: "{{ lookup('file', item) | from_yaml }}"
      when: "'backup_job_templates' in item"
      with_fileglob:
        - exports/backup_*.yml
      loop_control:
        label: "{{ item | split('/') | last }}"
1 Like