How about writing a shell script with ansible-playbook command, and triggering that every 30 minutes using crontab.
On Tue, Apr 21, 2020 at 11:02 AM Samir Kothawade <[email protected]> wrote: > Hi, > > I want to execute specified task in ansible playbook after every 30 mins. > Task is not just a command, so "at" module does not work in my case or may > be I am not doing it in proper way : > > Here is my play book. Playbook below runs correctly for single time. I > want to collect the stats after every 30 mins, so how should I do that... > Can you guys please suggest solution ? > > - hosts: zmr > gather_facts: no > vars: > date: "{{ lookup('pipe', 'date +%Y%m%d-%H%M') }}" > tasks: > - name: set the winsize > shell: stty cols 5000 rows 5000 > - name: Get the debug status > ignore_errors: yes > expect: > command: /opt/wishu/ZMR_Platform/bin/go_zmr_cli > timeout: 5 > responses: > (.*)Username:(.*): "admin" > (.*)Password:(.*): "admin" > (.*)ZMR>(.*): display debug info PP ip 192.168.30.26 port 8686 > (.*):(.*): " q" > timeout: 30 > register: stats > - local_action: copy content="{{ stats_.stdout}}" > dest="/home/sam/stats_{{ lookup('pipe', 'date +%Y%m%d-%H%M') }}.txt" > ignore_errors: yes > > -- > 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/43514f7d-40fb-4262-b7de-1a7921edbc0a%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/43514f7d-40fb-4262-b7de-1a7921edbc0a%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Thanks, Abhijeet Kasurde -- 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/CAFwWkHqi%3DHqR2bUsyqxRY-ov39JjbPpCh5chTrMOU_VneAxoPA%40mail.gmail.com.
