Hello all,
I was reading a resource that was covering some fundamentals on Ansible, and when I got to the short section on modules, the following sentence appeared: "When used in a task, a module generally ensures that some particular aspect of the machine
is in a particular state."
What's prompting a query from me is the piece that I've highlighted in red. I immediately
asked myself why the need to begin the sentence with "When used in a task". In a
playbook, is a module used in any place other than a task?
Thanks all.
Hi,
You can use modules in ad hoc commands as well.
E.g.
ansible atlanta -m ansible.builtin.copy -a "src=/etc/hosts dest=/tmp/hosts"
But the sentence you posted applies to ad hoc commands as well.
I can't think of any way to use a module where this would not apply.
HTH
It helped very much.
Many thanks Bran.
Hello,
hold in mind ...
One playbook (yml file) consists of one or more plays which run one or more tasks against one or more hosts.
Playbook (yml file)
|-- Play
|----Tasks
|------ Task with one module (eg. debug, user, copy, ...)
|------ Task with one module (eg. debug, user, copy, ...)
|------ Task with one module (eg. debug, user, copy, ...)
|-- Play
|----Tasks
|------ Task with one module (eg. debug, user, copy, ...)
|------ Task with one module (eg. debug, user, copy, ...)
Regards
Andreas
Very big help!!!
Thanks Andkra.
Hi @Trevor_Chandler ,
As @andkra and @BramMertens mention, we cannot come up with a situation where modules are used outside of a task. It just meant to clarify the usage, it may look like overhead.
ansible adhoc IHMO is just starting a single task outside a playbook.
Regards,
Jan Gerrit
Wonderful explanation JG.
Very big help.
Many thanks!!!!
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.