There appears to be both 'k=v' shorthand syntax and YAML in this task.

Good day all,

I am new to Ansible, I am getting the following error while running a playbook any pointer ?

ansible 2.8.4

There appears to be both ‘k=v’ shorthand syntax and YAML in this task. Only one syntax may be used.
This error can be suppressed as a warning using the "invalid_task_attribute_failed" configuration

  • name: “Create multiple directories”
    file: path={{item}} state=directory
    with_items:
  • ‘/opt/services/tomcat/webapps/searchhub’
  • ‘/tmp/searchhub’
  • name: Copy the war
    copy: src=/home/searchhub.war dest=/tmp/ owner=tomcat group=tomcat mode=0755
  • name: “Change the ownership of the folder and Extract the war file to searchhub”
    shell: “/usr/bin/unzip -q -o -d /opt/services/tomcat/webapps/searchhub /tmp/searchhub.war”

become: yes

Regards
Gurudatta N.R

Hi Gurudatta,

As the error suggests, you have to use either ‘k=v’ syntax throughout the playbook or yaml throughout the playbook. More recent conventions suggest using yaml, so try this.

  • name: “Create multiple directories”
    file:
    path: {{item}}
    state: directory
    with_items:
  • ‘/opt/services/tomcat/webapps/searchhub’
  • ‘/tmp/searchhub’
  • name: Copy the war
    copy:
    src: /home/searchhub.war
    dest: /tmp/
    owner: tomcat
    group: tomcat
    mode: 0755
  • name: “Change the ownership of the folder and Extract the war file to searchhub”
    shell: “/usr/bin/unzip -q -o -d /opt/services/tomcat/webapps/searchhub /tmp/searchhub.war”

become: yes

Thank you Michael, For your timely help.### RegardsGurudatta N.R

There also appears to be some issues with the indentation, although that could be an artifact of mail.

The tasks look like they are in k=v syntax, but if the following -name is indented it could be considered part of the same task.