to iterate over a hosts group you need with_items: groups['mysql'] instead
of with_dict
On Tuesday, 13 January 2015 09:41:07 UTC+1, Laurent Goussard wrote:
>
> Hello,
>
> I try to setup a cron task using ansible (indeed) on my db slave pool.
> This cron task is supposed to stop the replication process, dump the
> database and restart replication.
> Because the backup takes a little time, I don't want to init the cron task
> at the same time on all the db slaves and I don't want to stop all the
> slaves at the same times either.
>
> My first idea was to set a different time while looping on the group.
> But it's definitely not as trivial as it seems :
>
> - name: database backup cron task
> cron: name="database backup" hour={{ item.key }} user="root" job=
> "backup_db.sh" cron_file=database_backup
> with_dict: groups.mysql
>
> The point is an inventory group is a list, not a dictionnary and I cannot
> find any simple way to convert a list to a dict (whereas it's easy to
> convert a dict as a list)
> I also tried to use the group list instead, but I cannot figure out how I
> can get an iterator key.
>
> Did I miss something ? Do you have any clue regarding my (not so complex
> imho) problem ?
>
--
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/884b96af-215c-4861-8520-738d5daaa840%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.