Search code examples
linuxansibleansible-template

I am getting error like ERROR! unexpected parameter type in action: <class 'ansible.parsing.yaml.objects.AnsibleSequence'>, when running ansible


When i am trying to run this code in ansible, i am getting error like

ERROR! unexpected parameter type in action: <class 'ansible.parsing.yaml.objects.AnsibleSequence'
The error appears to be in '/home/c22377/icoms1.yml': line 15, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
  handlers:
    - name: starting one time job
      ^ here

I need to use handlers, can you correct me?

---
- hosts: catl
  name: "checking file ran or not"
  tasks:
    - shell: tail -1 test/test.log|awk '{print $8,$9,$10}'
      register: result
    - shell: date | awk '{print $1,$2,$3}'
      name: checking todays date
      register: time
    - debug:
             msg: "{{ result.stdout }}"
      when: result.stdout == time.stdout
      notify: starting one time job
  handlers:
    - name: starting one time job
      tasks:
        - shell: date

Solution

  • Change from:

    handlers:
    - name: starting one time job
      tasks:
      - shell: date
    

    to:

    handlers:
    - name: starting one time job
      shell: date