The following playbook worked for me, but I just started with Ansible and 
I'm wondering if I went about this wrong? I feel like I may have missed an 
easier way to say: do something only after a package has finished 
installing ... 
tasks: - name: Install python3 with a specific command and register stdout 
to a var command: sudo yum -y install python3 python3-pip register: varname 
- name: Create a directory only after python3 has been installed file: 
path: /home/ec2-user/newdirectory state: directory when: 
varname.stdout.find("Complete!") != -1 


 







On Thursday, March 21, 2019 at 2:24:58 PM UTC-7, [email protected] wrote:
>
> Hello,
>
> I have two tasks in a playbook. The first task installs software with the 
> command module. The second creates a file. I don’t want the second task to 
> run until the software has finished installing. I’m pretty sure I need to 
> use “when”, but I’m not sure what to evaluate to determine that the 
> software has finished installing.
>
> I’m thinking that I could use the stdout of this yum command? The last 
> line output to the screen is “Complete!” would it be possible to base the 
> “when” on the existence of that text string in stdout?
> something like:
>
> - name: Install python3 with a specific command and register stdout to a 
> var
>   command: sudo yum -y install python3 python3-pip
>   register: stdout 
>
> - name: Create a directory after python3 has been installed 
>
>     file:
>
>       path: /home/newdirectory
>
>       state: directory
>
>       when: [a line of text in stdout] == "Complete!"
>
>  
> Does this logic even make sense? I assumed that "register" would put all 
> of stdout into an array of lines of strings, but I don't if that's how it 
> works or not or how to search stdout for the string "Complete!"? 
>
> Thanks much for any help 
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/cdc8e599-deb7-4c7c-b94f-a2494feef196%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to