Ansible Module shell

From NovaOrdis Knowledge Base
Revision as of 19:43, 12 July 2021 by Ovidiu (talk | contribs) (→‎Example)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

External

Internal

Example

ansible -i ./hosts -b --become-user=root all -m shell -a 'ls -al'
- name: IDEA application histories
  shell: "cat \"{{ item.path }}\""
  with_items: "{{ some_var | list }}"
  register: some_other_var
  changed_when: false

shell can be used to run complex shell pipelines, set/unset environment variables in the execution environment, etc:

- name: test shell
  shell: "{ unset JAVA_HOME; /usr/libexec/java_home -v 11; }"
  register: execution_result