Tested the async feature having only one task in the apache_task.yaml file 
without collecting the result to csv file and it was successful.
Can you help to check the server status and append to a file in a single 
task?

On Monday, 12 November 2018 15:25:41 UTC-5, Saravanan wrote:
>
> Hi Ansible Expers,
> Can you please share your valuable suggestions/ inputs to improve the 
> performance of the playbook?
>
>
> On Nov 12, 2018, at 1:04 PM, Saravanan <[email protected]> wrote:
>
> Hi Team,
> Herewith I am sharing my core playbook and another yaml playbook used for 
> iteration to get the apache server status, storing them to a file. This 
> playbook takes longer time to complete the task on all hosts. To speedup he 
> execution, I would like to include async in the play. 
> Please check these files and share your suggestion on how best we can 
> implement async to speed up the playbook execution. 
>
> *apache_monitoring.yaml*
>
> ---
> - name: Apache server check
>   gather_facts: no
>   hosts: 127.0.0.1
>   strategy: free
>
>   tasks:
>     - name: Create csv file and html file
>       file:
>         path: "{{ item }}"
>         state: touch
>       delegae_to: localhost
>       become_user: awx
>       become: no
>       with_items:
>         - /tmp/apache.csv
>         - /tmp/apache.html
>
>     - include_vars: apache_sever_list.yaml
>
>     - include_tasks: apache_task.yaml
>       with_items: '{{ apacheSevers }}'
>
>     - name: Run the csv2html script
>       shell: |
>         echo "<h3>List of failed Apache servers</h3>"
>         echo "<table>" ;
>         echo "<table><tr><th>Hostname</th><th>Port</th></tr>"
>         while read INPUT; do
>         echo "<tr><td>${INPUT//,/</td><td>}</td></tr>";
>         done < /tmp/apache.csv
>         echo "</table>"
>       delegae_to: localhost
>       become_user: awx
>       become: no        
>
>     - name: append
>       lineinfile:
>         dest: /tmp/apache.html
>         line: "{{ output.stdout }}"
>         insertafter: EOF
>       delegae_to: localhost
>       become_user: awx
>       become: no
>
>     - name: Send out email
>       local_action: mail
>                     host='127.0.0.1'
>                     port=25
>                     subject="Apache servers not running"
>                     body="{{ lookup('file', '/tmp/apache.html') }}"
>                     from="[email protected]"
>                     to="[email protected]"
>                     secure="never"
>                     subtype="html"
>                     charset=utf8
>       delegae_to: localhost
>       become_user: awx
>       become: no
>       run_once: true
>
>     - name: Clear csv file and html file
>       file:
>         path: "{{ item }}"
>         state: touch
>       delegae_to: localhost
>       become_user: awx
>       become: no     
>       with_items:
>         - /tmp/apache.csv
>         - /tmp/apache.html
>
>
> *apche_task.yaml*
>
>     - name: Check the apache server status
>       uri:
>         url: "{{ item.hostname }}:{{ item.port }}"
>         method: GET
>         status_code: 200
>         body_format: raw
>         follow_redirects: all
>         return_content: yes
>         validate_certs: no
>         force: yes
>       delegae_to: localhost
>       become_user: awx
>       become: no
>
>
>     - name: append output to file
>       lineinfile:
>         dest: /tmp/apache.csv
>         line: "{{ item.hostname }},{{ item.port }}"
>         insertafter: EOF
>       delegae_to: localhost
>       become_user: awx
>       become: no  
>
> -- 
> 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/088c8c9f-a7e1-43ed-8104-df4db7ca6d49%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/ansible-project/088c8c9f-a7e1-43ed-8104-df4db7ca6d49%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>

-- 
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/1d8f5f67-f47e-4978-9cae-14336f1c881c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to