The difference between a “command” or a specific module execution in Ansible

I start with Ansible, and I found that there is a module called commandthat allows me to execute any command on the remote node.

I saw a couple of examples where the initial settings are solved using commandspecific modules instead. For example, as far as I know, both of them perform the same task:

- name: Install git using apt module
  apt:
    name: git
    state: present

- name: Install git using command
  command: apt-get install git

So my question is: is there any difference or any reason to use a module instead of a command?

+4
source share
2 answers

, .

? :

- name: Install git using apt module
  apt:
    name: git
    state: present

git , (OK), git .

command:

- name: Install git using command
  command: apt-get install git

changed ( ), (, git ). , idempotent command, .

command .

Ansible - . playbook , , , changed, . , , .

command vs specific module:

: The Essentials

+4

, , , :

  • ( )
  • ( , )
  • ( )
  • - ( )
+3

Source: https://habr.com/ru/post/1662015/


All Articles