Re: [ansible-project] Ansible -Calling a playbook inside a playbook with vars_prompt giving error : ERROR: vars_prompt is not a legal parameter in an Ansible task or handler

987 views
Skip to first unread message

Michael DeHaan

unread,
Aug 18, 2014, 8:32:20 AM8/18/14
to ansible...@googlegroups.com
Looks like you are missing a tasks section and also have some indent issues.




On Mon, Aug 18, 2014 at 6:55 AM, Imran Khan <khan.im...@gmail.com> wrote:

I have a tikitaka3.yml (main yml file) and a tikitaka3a.yml (playbook to be included) . When I prompt the user for a variable and then in the tasks section when I call it, like so

---
- hosts: all

 vars:
   khan:

  vars_prompt:
- name: targetenv
  prompt: "Select group to modify 1.)EPC 2.)CLIENTS 3)TESTERS"
  private: False
  default: "1"


- name: Inlude playbook tikitaka3a
  include: /home/khan/Desktop/playbooks/tikitaka3a.yml target=targetenv
  when: targetenv.stdout|int < 2 #this condition does not work, explained below
  #when: targetenv == 1 or "1" #this doesn't work either

- name: Debugging
  debug: var=targetenv.stdout

I get this error when I run the playbook "ERROR: vars_prompt is not a legal parameter in an Ansible task or handler"

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/61a62923-7904-4a0e-9886-7239d53d67bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Imran Khan

unread,
Aug 19, 2014, 3:54:27 AM8/19/14
to ansible...@googlegroups.com
Thanks for the quick reply. I fixed those issue, but the main problem remains. The if condition is not evaluated. 
P.S: I am going off topic here, but is there any way for me to place a when condition on a complete playbook or say for the first 10 tasks in a playbook etc?

Michael DeHaan

unread,
Aug 19, 2014, 2:41:07 PM8/19/14
to ansible...@googlegroups.com
On the first part, can you show your new playbook and the output?

As to your question, yes.


- hosts: all
  tasks:
     - group_by: key=test-{{ a > b }}

- hosts: test-True
  tasks: # or roles, here, etc
     - ping

- hosts: tests-False
  tasks:
     - ping

The group_by module basically carves up hosts based on arbitrary criteria, creating dynamic groups that are very useful for this sort of thing.





Imran Khan

unread,
Aug 20, 2014, 1:08:00 AM8/20/14
to ansible...@googlegroups.com
Thanks mate, I'll give this a try!
Reply all
Reply to author
Forward
0 new messages