Dear all,
I get this advise by use the very nice lint feature of ansible-navigator
I already consulted the docs about ansible.builtin.dnf
Wat kind of data need to be used add the key/value "state:"
CLI:
[student@workstation playbook-review]$ ansible-navigator lint internet.yml -m stdout
package-latest: Package installs should not use latest.
internet.yml:6 Task/Handler: Install Software
Snippet:
tasks:
- name: Install Software
ansible.builtin.dnf:
name:
- firewalld
- httpd
- mariadb-server
- php
- php-mysqlnd
state: latest
Best regards,
Bert
@Maxxranger I think --syntax-check will perform syntax validation without executing any tasks and in the output you will get errors or success based on the validity of the syntax whereas
--check is what is called as Dry RUn which means it will pretend to execute those tasks but will not make any changes and in the output you will see things like changed , ok or skipped based on assumtptions if the playbook was actually run.
https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_checkmode.html
@Chetan_Tiwary_ - you're 100% right, --syntax-check does nothing. The --check will as you stated do a Dry Run. What I am cautioning though is that even with modules that support Dry Run, this could be turned off in the configuration file, an environment variable, or at the playbook/task level, so it is always a good idea to check. Also, I know the yum and dnf modules support the dry run, but if there are other modules in the playbook that aren't supporting dry run or you have command, shell, raw modules in use, those aren't even idempotent, so you need to take special care.
Since you are using ansible-navigator command, I highly encourage doing a Lint on the playbook as that is much better than --syntax-check which only tells you that the YAML appears to be properly formatted and doesn't even let you know if the playbook will run.
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.