0

I have AWX running as an operator on OpenShift. I need to export the templates and projects to take it to a new environment. When I try the export module, it uses the localhost and says connection refused to localhost:443.

When I located the Control Manager on one of the nodes, Ansible cannot SSH into it. Likely because it is a Worker Node on the Kubernetes cluster.

In this situation I am wondering how the export needs to be done?

Playbook looks as follows:

- name: Playbook to export templates
  hosts: workerhostname

  tasks:

  - name: Export all job templates
    become: yes
    awx.awx.export:
      job_templates: 'my_template'
      credentials: 'all'
      projects: 'all'
      all: True
      validate_certs: false
      controller_host: 'https://workerhostname:443'
      controller_username: 'admin'
      controller_password: '<masked'
      controller_oauthtoken: '<masked>'
    register: export_output  

  - name: Save export to file
    copy:
      content: "{{ export_output['assets'] }}"
      dest: export.json
U880D
  • 8,601
  • 6
  • 24
  • 40
Rishi S
  • 353
  • 1
  • 5
  • 16
  • 1
    "_When I try the export module, it uses the localhost_", right, as far as I've seen that might be the case. The use case "_I need to export the templates and projects to take it to a new environment._" can become quite complex. You could export from the (external) application database, export from or via REST API calls, use Terraform and an Ansible Tower provider, export via CLI tools, etc. ... – U880D Feb 23 '23 at 13:11
  • 1
    Running that module directly on your awx host seems a bit of a non-sense. The best target for your play is probably `hosts: localhost` or any other host you have access to from ansible and that is able to reach awx through http. In `controller_host` in the task you should add as first approach the fqdn of awx you use daily in your browser. You can probably make this more performant afterwards by using from awx the local fqdn of your awx service inside openshift but that's an other story. Note this is off-topic here as it is not a programming question. Consider moving to https://serverfault.com – Zeitounator Feb 23 '23 at 15:25
  • @U880D : when you say REST calls, you mean there is a REST API that AWX provides to export ? I will explore that approach - seems the best one to use if that works. I am not sure what the database structure is to figure out what to export from the db, if I have to use that approach. – Rishi S Feb 23 '23 at 16:34
  • 2
    @RishiS the module you are trying to use **is** using the awx REST api to export data. – Zeitounator Feb 23 '23 at 16:52
  • An example for working with AWX / Tower REST API and Job Templates is [checking for unused templates](https://stackoverflow.com/a/73319490/6771046). – U880D Feb 24 '23 at 10:24

0 Answers0