I know it's possible to run multiple adhoc commands one after the other for each module and using playbook.
Playbook:
- hosts: webservers
tasks:
- name: create .ssh dir
file: path ~/.ssh state=directory
- name: copy pub key
copy: src:~/.ssh/id.rsa_pub dest=~/.ssh/authorized_keys
I want the above to execute using adhoc in one line. Is it possible to do so?
No, it is not possible.
ansible
command accepts only one set of arguments for a single module and its parameters.
-m MODULE_NAME, --module-name=MODULE_NAME
module name to execute (default=command
)