3

I'm trying to write an Ansible playbook which will take a bash-script, stored on the same virtual machine, transfer this script to another virtual machine and then execute it. I've played this script on Ansible AWX and I've modified this script many times, trying copy: module, template: module and script: module and I gain every time the same mistake (see the applied pictures). It looks like Ansible AWX doesn't have rights to file system, where it is installed and I have no idea, why it is so.

Update: I think the thing is that AWX is installed in docker container. At the moment I don't know how to add correctly script to awx-container.

Script:

script body

Error:

failure body

Linux directory:

linux directory

Worthwelle
  • 4,538
  • 11
  • 21
  • 32

2 Answers2

0

I don't use AWX but try delegate_to on the copy task:

- name: delegate script
  script: /example/script.py
  args:
    executable: bash
  delegate_to: awxVMexample

If your AWX host is not known in your inventory you can use add_host

- name: add awx
  add_host:
    name: awxVMexample

And a general tip: use the code tags to show your example code instead of a screenshot.

HoD
  • 3,277
  • 15
  • 19
0

I've solved this problem. In the directory /root/awx/installer where are placed files: "build.yml", "install.yml", "inventory", "roles" I have changed file "inventory" as you can see on the screenshot "inventory.jpg". Then I've ran: "# ansible-playbook -i inventory install.yml" to reinstall AWX and created directory "/var/lib/awx/projects" under my username (not root), where I've placed "sscript.sh". I've modified playbook as following, see "script.jpg", updated repository in AWX and executed job there. It works fine now.

inventory.jpg script.jpg