0

I am working on Ansible. I see that we create roles and then under "tasks" folder we create main.yml. In this file, we specify which commands should be performed for this specific role. While writing these commands we use a set of modules.

There is also this concept of ad-hoc ansible commands which is another place where we can run commands using modules.

I was wondering if all the modules are available for typing ad-hoc commands or only a subset of them?

0

I can't think of an instance where you would not be able to run an ansible module in ad-hoc mode, assuming the module is appropriate for the target host. Also, all modules must conform to the same standard (most notably return all output as JSON). Because you can add all module arguments in via the "-a" flag using ansible in ad-hoc mode, functionally it's not different than executing the same command/task from a playbook (make no mistake though, playbooks are far more powerful).

Ad-hoc commands are very useful to perform quick tasks and/or checks, but anything further than that should probably be a playbook. A better overview can be found in the official docs: https://docs.ansible.com/ansible/latest/user_guide/intro_adhoc.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.