Hi Tom, 

Can you try a couple of options and post it to this thread please ? 
With the same inventory file: 

[mysql] 
  mysql01 
  mysql02 
  mysql03 
  mysql04



ansible-playbook -i infra --limit mysql02 main.yml --tags "mysql" -v

ansible-playbook -i infra --limit mysql03 main.yml --tags "mysql" -v


Thnx, 
Stephen

On Wednesday, November 14, 2018 at 9:15:38 AM UTC-5, Kai Stian Olstad wrote:
>
> On 14.11.2018 14:49, Tom K. wrote: 
> > On Tuesday, November 13, 2018 at 3:10:18 AM UTC-5, Tom K. wrote: 
> > 
> > Ok.  So I removed a couple of tags from the mysql task "mysql : Copy 
> > my.cnf 
> > global MySQL configuration."  and adjusted the play as follows: 
>
> The playbook is fine, the problem is the limit option your are using on 
> ansible-playbook. 
>
>
> > [root@awx01 ansible]# vi main.yml 
> > --- 
> > - name: Gather all facts prior to execution 
> >   hosts: mysql 
> >   gather_facts: true 
> >   tasks: 
> >     - debug: msg='{{ inventory_hostname }} has default IP {{ 
> > ansible_default_ipv4["address"] }}' 
> >     - template: 
> >         src: test.j2 
> >         dest: /tmp/test.out 
> >   tags: mysql 
> > 
> > 
> > - name: Install and configure MySQL 
> >   hosts: mysql 
> >   become: true 
> >   roles: 
> >     - mysql 
> >   tags: mysql 
> > 
> > 
> > But that didn't work.  Still got the original error with mysql04.   
> > Until I 
> > removed mysql01-3 from the infra file leaving only mysql04: 
> > 
> > [mysql] 
> > mysql04 
> > 
> > 
> > And reran using: 
> > 
> > ansible-playbook -i infra --limit mysql04 main.yml --tags "mysql" -v 
>
>
> You still have the same problem I commented on earlier. 
>
> When you run a with --limit, the task and *gather_facts* is only run on 
> host specified in the limit. 
> So when you in you template try using facts for mysql01-03 they don't 
> exist since you haven't gather them so you get the error message. 
>
> So remove you --limit and it will work, the template you have will never 
> work if you specify limit. 
>
>
> -- 
> Kai Stian Olstad 
>

-- 
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fcb52497-8ebf-419a-b017-4347e978d0e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to