Prompt question again. Thanks

69 views
Skip to first unread message

Tiglath

unread,
Oct 15, 2014, 2:02:10 PM10/15/14
to ansible...@googlegroups.com
 
Between my lack of Ansible mastery and its kind of syntax, rare is the day I don't get stuck... 
 
Either the syntax is not intuitive or I have no intuition. 
 
I am trying to do something very simple and it seems very complicated in Ansible.  I hope it just seems so. 
 
I  figure out what release to deploy in a play and then confirm the release is correct, if not all stops, if correct run with the wind...
 
So:
 
If I put vars_prompt between the tasks it gives an error.   Where can the prompt go then?    When is code position indicative of order of execution and when not? 
 

---

hosts: appserver

tasks:

- name: Get the latest release.

   local_action: shell grep XXX  /tmp/releases | cut -f2 -d':' | tr -d "," | tr -d "'"

   register: rel

--->>><  "Deploying release {{ rel.stdout }} Correct?  (y/n): "  > prompt goes here  <<< ----  

- name: Remove old installation files.

  script: /tmp/clean.sh "{{ rel.stdout }}"

- name: Run local build.

  local_action: shell /tmp/build.py "{{ inventory_hostname }}" "{{ rel.stdout }}"

- name: Run deploy.py on target.

script: /export/home/jsuriol/deploy/migration/apps/TV2G/tools/deploy.py "{{ rel.stdout }}"

Thank you for your patience with neophites... 

 

 

Michael Peters

unread,
Oct 15, 2014, 2:16:13 PM10/15/14
to ansible...@googlegroups.com
vars_prompt goes on the play level, not the task level. It's not a
task and you don't have control over when the prompt happens. It will
ask you before the play starts to answer any questions in the prompt.

Just a helpful way to think about what can go in the task list: Is it
a module? (
http://docs.ansible.com/list_of_all_modules.html). If not, then it
can't be a task.
> --
> 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/1bbaf9f6-56df-41fa-b3fb-c78faa2d980b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Tiglath

unread,
Oct 15, 2014, 3:12:50 PM10/15/14
to ansible...@googlegroups.com

Good rule.  Thanks

Brian Coca

unread,
Oct 16, 2014, 8:47:01 PM10/16/14
to ansible...@googlegroups.com

Look at the pause module for this functionality

Brian Coca

Michael Peters

unread,
Oct 17, 2014, 9:54:29 AM10/17/14
to ansible...@googlegroups.com
I could be wrong, but from my understanding the pause module won't
take input. It will give a prompt, but that just waits for enter to be
pressed right?
> https://groups.google.com/d/msgid/ansible-project/CADn%2BHsyUnGB5ONav6OACqGbbpYNq4BhcNWiEWfQUg9jRXo_1hA%40mail.gmail.com.

Brian Coca

unread,
Oct 17, 2014, 6:22:37 PM10/17/14
to ansible...@googlegroups.com

You can give input which is available through registered variables

Reply all
Reply to author
Forward
0 new messages