Ansible playbook errors: multiple tasks in a single playbook

15 views
Skip to first unread message

Surya Ahuja

unread,
Oct 15, 2018, 12:17:36 AM10/15/18
to Ansible Project
I am a noob at ansible, and I am trying to learn it to automate log collection for our lab. My yaml file is right below: Executing this gives me an error near the second set of tasks. I am searching everyhwere but what  am actually confused about is this:. Is this allowed ? As far as I have read, hosts: x tasks: A hosts:y tasks:B should be allowed. Then why am i seeing this error?
Thanks,
Surya




---
- name: Transfer script, get the file
  hosts: qemu_vm
  sudo: yes
  tasks:
        - name: Transfer the script to remote host
          copy: src=~/CPU_logs.sh dest=~ mode=0777

        - name: Execute the script on Remote host
          command: sh ~/CPU_logs.sh

        - name: Get the file
          fetch:
                src: ~/CPU_logs.csv
                dest: /var/customlogs/logs/{{ inventory_hostname }}
                flat: yes

- name : Run script on host, save the file in /var/customlogs
  hosts: host_vm
  sudo: yes
  tasks:
        - name: Run the script
          command: sh ~/CPU_logs.sh

        - name: Get the file
          fetch:
                src: ~/CPU_logs.csv
                dest: /var/customlogs/logs/{{ inventory_hostname }}
                flat: yes

Brian Coca

unread,
Oct 17, 2018, 4:18:24 PM10/17/18
to Ansible Project
It helps to include the error you are asking about.


--
----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages