Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does state=installed mean in ansible apt?

Tags:

ansible

What does state=installed mean in ansible apt?

- name: Install Node.js
  apt:
    pkg:
      - nodejs
    state: installed
    update_cache: yes

It is not mentioned in the docs nor elsewhere.

like image 793
Adriano Di Giovanni Avatar asked Oct 06 '16 18:10

Adriano Di Giovanni


People also ask

What does state present mean in Ansible?

State as 'Present' and 'Installed' are used interchangeably. They both do the same thing i.e. it will ensure that a desired package in your case 'yum' is installed. Whereas State as 'Latest' means in addition to installation, it will go ahead and update if it is not of the latest available version.

What does APT mean in Ansible?

Ansible's apt module is used to manage packages with the apt package manager, which is the default on Debian based Linux distributions such as Debian and Ubuntu. Most systems require root/superuser permissions to manage packages, which means that become: true is required.


1 Answers

If we look into the code:

# Deal with deprecated aliases
if p['state'] == 'installed':
    p['state'] = 'present'
if p['state'] == 'removed':
    p['state'] = 'absent'

installed is a deprecated form of present,
removed is a deprecated form of absent.

like image 51
Konstantin Suvorov Avatar answered Nov 15 '22 08:11

Konstantin Suvorov