Some parameters are shown as illegal while running --check option in playbook

51 views
Skip to first unread message

santos...@quantil.com

unread,
May 24, 2016, 5:54:27 AM5/24/16
to Ansible Project
Hi All,

I am trying to do a syntax check on all my .yaml files before running ansible-playbook. I am using version 2.0.2.0. However some modules give error saying that they are "illegal parameters" in an Ansible play.

I am using  role based system and these "illegal parameters" are in my roles/ROLENAME/tasks/main.yaml files. Examples of these parameters are fail,register. However the funny thing is that the playbook runs absolutely fine. Only when i do ansible-playbook myYAMLFILE.yaml --check do I get these errors. Sample errors:

ERROR: fail is not a legal parameter of an Ansible Play

ERROR: register is not a legal parameter of an Ansible Play

Sample playbook:

---

- fail: msg="Please provide a profile name. Profile name can be qa|qa2|prod1|prod2|staging"
  when: profile is undefined

- fail: msg="Invalid profile. Profile name can be qa|qa2|prod1|prod2|staging "
  when: not((profile == 'qa') or (profile == 'qa2') or (profile == 'prod1') or (profile == 'prod2') or (profile == 'prod3') or (profile == 'staging'))

#Extract the file name pointed to by the mwportal link
- name: Get file name of the war file to deploy
  local_action: shell readlink -f {{local_repo}}apiserver
  register: res

- set_fact:
    war_file_dir_absolute_path="{{remote_repo}}{{ res.stdout.split('/')[-1].split('.')[0] }}"
    war_file_dir_basename="{{ res.stdout.split('/')[-1].split('.')[0] }}"

- debug: msg="{{war_file_dir_absolute_path}}"

- name: create a dir to unzip war file
  file: name={{war_file_dir_absolute_path}} state=directory

- name: Unzip the war file
  unarchive: src={{local_repo}}apiserver dest={{war_file_dir_absolute_path}}


#Copy the profiles from the WEB-INF/classes/profiles/XX directory to WEB-INF/classes
- name: Copy properties files to WEB-INF/classes
  shell: cp {{war_file_dir_absolute_path}}/WEB-INF/classes/{{profile}}/* {{war_file_dir_absolute_path}}/WEB-INF/classes/

- name: Ensure there are no residual folders from previus failed installation
  command: rm -rf /usr/local/{{war_file_dir_basename}}-{{profile}}
  #notify:
    #- Restart Tomcat7

- name: Move the war file to /usr/local
  command: mv {{war_file_dir_absolute_path}} /usr/local/{{war_file_dir_basename}}-{{profile}}
  # notify:
  #   - Restart Tomcat7

- name: Create a symlink
  file: name=/usr/local/apiserver src={{war_file_dir_basename}}-{{profile}} state=link force=yes
  # notify:
  #   - Restart Tomcat7

- name: Restart tomcat
  service: name=tomcat7 state=restarted

...

Am I doing something wrong here? If check is not the correct way to check the correctness of YAML config then what is?

Thank you.

Brian Coca

unread,
May 25, 2016, 5:33:16 PM5/25/16
to ansible...@googlegroups.com
what you are showing is NOT a play, but a task list, you need a play (normally - hosts: )


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