I am trying to list the directory size of certain directory in list of servers. In the below playbook the ruby script along with ansible task will create file with all instance details and saving it in region-ec2-list.txt. What I need in lineinfile is to, it should insert the set_fact output to file /tmp/disk-ec2-list.txt below the line {{ inventory_hostname }} as the output of the ruby script will have same {{ inventory_hostname }} , that is public ip
- name: Listing ec2 instance in all regions(us-east-1", "us-west-1", "us-west-2", "eu-west-1", "eu-central-1", "ap-southeast-2) local_action: command /usr/bin/ruby /root/sree/test/list-all.rb "{{ corp_aws_key_id }}" "{{ corp_aws_secret_access_key }}" register: output_ruby run_once: true - name: copy output to file local_action: copy content="{{ output_ruby.stdout }}" dest="/tmp/disk-ec2-list.txt" - name: Execute du -sh /var/lib/mysql command: du -sh /var/lib/mysql register: disk_usage_mysql - set_fact: mysql={{ disk_usage_mysql.stdout }} - name: Execute du -sh /usr/local/zephyr/zephyrdata/attachment command: du -sh /usr/local/zephyr/zephyrdata/attachment register: disk_usage_zephyrdata - set_fact: zephyrdata={{ disk_usage_zephyrdata.stdout }} - name: debug debug: var="{{ inventory_hostname }} {{ mysql }} {{ zephyrdata }}" - name: localaction # local_action: copy content= "{{ inventory_hostname }} {{ mysql }} {{ zephyrdata }}" dest="/tmp/disk-ec2-list.txt" # local_action: lineinfile dest=/tmp/disk-ec2-list.txt insertafter=EOF line="{{ inventory_hostname }} {{ mysql }} {{ zephyrdata }}" create=yes In short: how to insert a file using lineinfile after string "{{ inventory_hostname }}" please help. Also let me know if anymore details is required -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/910dfb1c-8907-48f6-96c5-ea58430d4964%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.