please explain me. How can I access to answer one prompt on another server? my hosts
:
[dbs]
db1
db2
db3
I have one role and mytasks/main.yml
is:
- pause:
prompt: "Do you want to install mysql (yes/no)?"
register: install_mysql
- include_tasks: mysql.yml
when: install_mysql.user_input | bool
when I execute this role, only first server skip toMySQL.yml
another server execute.MySQL.yml
I want if the user enters forno
answer prompt,MySQL.yml
does not execute for any server. but when I enter no It will be installed again!!
[root@anisble ansible]# ansible-playbook playbooks/test.yml
PLAY [dbs]
**************************************************************
TASK [Gathering Facts]
*******************
ok: [db1]
ok: [db3]
ok: [db2]
TASK [ssh : pause]
********************************************************************************
[ssh : pause]
Do you want to install mysql (yes/no)?:
no
ok: [db1]
TASK [ssh : include_tasks]
********************************************************************************
skipping: [db1]
included: /etc/ansible/roles/ssh/tasks/mysql.yml for db2, db3
TASK [ssh : install mysql]
********************************************************************************
ok: [db3]
ok: [db2]
PLAY RECAP
********************************************************************************
db1 : ok=2 changed=0 unreachable=0 failed=0
db2 : ok=3 changed=0 unreachable=0 failed=0
db3 : ok=3 changed=0 unreachable=0 failed=0
Also, I check this method :
---
- pause:
prompt: "Do you want to install mysql (yes/no)?"
register: install_mysql
delegate_to: localhost
- include_tasks: mysql.yml
when: hostvars['localhost']['install_mysql']['user_input'] == 'yes'
but The same output becomes.