Loop over a list of dicts.
On Wed, 8 Jan 2020 at 18:57, Xinhuan Zheng <[email protected]> wrote: > Hello, > > I'm creating a Ansible role to place a set of scripts to managed hosts so > that they can start by cron in a defined schedule. Since it is a set of > scripts, I want to generalize the play execution sequence to use a loop. > This will be before loop: > > --- > > - name: Create directory > file: > path: /mydirectory > state: directory > owner: root > group: root > mode: 0755 > > - name: Install script1 > template: > src: script1.sh.j2 > dest: /mydirectory/script1.sh > > - name: Create cronjob for script1 > cron: > name: script1 run every minute > cron_file: script1_cron > user: root > job: /mydirectory/script1.sh > > - name: Install script2 > template: > src: script2.sh.j2 > dest: /mydirectory/script2.sh > > - name: Create cronjob for script2 > cron: > name: script2 run every 10 minutes > minute: */10 > cron_file: script2_cron > user: root > job: /mydirectory/script2.sh > > Since it is a set of scripts, I figured it would be possible to generalize > using loop but I don't know how. In place of script1/script2, it will be a > variable name. How do I generalize every minute, every 10 minutes, every > hour, or specific date & time as a variable within a loop? > > Thank you, > > - Xinhuan Zheng > > > > -- > 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 view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/2c5294c6-d1f6-4bd9-b1c6-7bf0bfb31ca2%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/2c5294c6-d1f6-4bd9-b1c6-7bf0bfb31ca2%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Sent from a mobile device - please excuse the brevity, spelling and punctuation. -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAL8fbwO6gUbx7Y_Uxpr_-o1iG%3DeJqdyZgSOh%2BMP35c2Q0rRTxA%40mail.gmail.com.
