Create a script (e.g. in bash) that does everything you want to do, including run Ansible.
Then create a cron-job which runs that script at the intervals you desire. Regards, K. On Tue, Apr 21, 2020 at 3:32 PM 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> > . > -- *Karl Auer* { manager, systems support } P: 1300 759 975 E: [email protected] 2pisoftware.com GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107 Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E -- 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/CA%2B%2BT08TZztrePCB2pj5kBQq%3Dfb8O0fj7LmpLKmn2Y8Qn9g2gFw%40mail.gmail.com.
