Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Everytime I run a playbook, ansible will install the packages again and again, even thought it is installed, so how does it work actually?

ansible-playbook -i hosts  site.yml
GATHERING FACTS *************************************************************** 
ok: [192.168.0.2]

TASK: [Install via apt] *************************************** 
changed: [192.168.0.2] => (item=build-essential,python-dev,python-software-properties,python-setuptools)

My cookbook (Tasks):

 name: Install via apt
  action: apt pkg=$item
  with_items:
    - build-essential
    - python-dev
    - python-software-properties
share|improve this question
1  
Please add the relevant portions of the playbook. –  dawud Aug 4 '13 at 8:09
    
@dawud, updated the question, thanks –  Ryan Aug 4 '13 at 13:08
1  
Can you isolate the issue outside Ansible? What happens when you apt-get install those packages? –  Willem Sep 19 '13 at 9:20

1 Answer 1

I can't reproduce your error with this playbook:

- hosts: 10.0.0.2
  sudo: yes

  tasks:

    - name: Install via apt
      action: apt pkg=$item
      with_items:
         - build-essential
         - python-dev
         - python-software-properties

As expected, consecutive executions of the playbook are idempotent:

$ ansible-playbook pkg.playbook -K
sudo password:

PLAY [10.0.0.2] *********************

GATHERING FACTS *********************
ok: [10.0.0.2]

TASK: [Install via apt] *********************
ok: [10.0.0.2] => (item=build-essential,python-dev,python-software-properties)

PLAY RECAP *********************
10.0.0.2                       : ok=2    changed=0    unreachable=0    failed=0
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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