My needs: Write a playbook which can install apache if the user wants to, while the playbook is running by typing yes or no.
apache_prompt.yml
hosts: slaves
vars_prompt:
- name: install_apache
prompt: "Do yo want to install apache? (yes/no)?"
tasks:
- name: if 'yes'
include_tasks: apache.yml
when: install_apache == 'yes'
apache.yml
---
- name: apache install
apt:
name: apache2
state: present
These playbooks are integrated in a role folder "apache"
My /tasks/main.yml
---
- import_tasks: apache_prompt.yml
My main playbook, which I use for installing some stuffs thanks to roles:
- hosts: slaves
roles:
- ntp
- nmap
- tcpdump
- unattended-upgrades
- apache
I only have trouble with the apache role.
------------------EDIT-------------------
I've got syntax error since I wrote my question. I tried to modify the
apache_prompt.yml
until now and i got this error: ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
---
- hosts: slaves
vars_prompt:
- name: "install_apache"
prompt: "Do yo want to install apache? (yes/no)?"
tasks:
- include_tasks: apache.yml
when: install_apache == 'yes'
when: install_apache == 'yes'
, is that correct? – Panki Mar 1 '19 at 12:06