I have a playbook that works great when I limit to a single host.
ansible-playbook -k playbook.yml group1
I need to be able to run it against multiple hosts at the same time. The syntax would be:
ansible-playbook -k playbook.yml 'group1 group2'
group 1 is a group that has several servers with different applications installed
server1 (this is the proxy server)
server2
server3
server4
group 2 is a group that has several servers with different applications installed
server5 (this is the proxy server)
server6
server7
server8
proxy is a group of all my proxy servers
server1
server5
I am polling a directory for a list of files to unzip, and asking the user for which file they want to use.
The task returns this:
TASK pause:
Choose the NUMBER of the file to select:
1--------files/jtt_test/file1.tgz
2--------files/jtt_test/file2.gz
3--------files/jtt_test/file3.tgz
4--------files/jtt_test/file4.jar
5--------files/jtt_test/file5.jar
The user picks a number and that is the file to be unarchived.
I run against group1 by itself and it works fine.
I run against group1 and group2 at once, and it errors out. I am assuming because it can not pass the variable of the file being chosen.
The playbook is this:
-name: Update UI files
hosts: proxy
tasks:
- find:
path: "files/{{ instance_dir }}"
register: result
delegate_to: localhost
- set_fact:
my_files: "{{ result.files|map(attribute='path')|list|sort }}"
- pause:
prompt: |
Choose the NUMBER of the file to select:
{% for file in my_files %}
{{ loop.index }}----------{{ file }}
{% endfor %}
register: result
- debug:
msg: "selected file: {{ my_files[result.user_input|int - 1] }}"
fatal: [proxy.local.test]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'user_input'\n\nThe error appears to be in 'playbook.yml': line 30, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - debug:\n ^ here\n"}
I am not sure how to resolve this.