ansible always reports changed

14 views
Skip to first unread message

Jost

unread,
Oct 19, 2018, 4:03:46 AM10/19/18
to Ansible Project
Hi

I have ansible 2.6.5 and I notice one strange think. If I use hard code path for  "item.dest"  then reports no changed. Change is reported only if I change something inside plugins which is OK

- name: install plugins
  copy:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
    mode: 0755
    owner: root
    group: root
  with_items:
    - { src: mk_logins,dest: '/usr/lib/check_mk_agent/plugins'}
    - { src: symantec_av,dest: '/usr/lib/check_mk_agent/plugins'}


TASK [check-mk-agent : install plugins] ***********************************************************************************
ok: [rhl1] => (item={u'dest': u'/usr/lib/check_mk_agent/plugins', u'src': u'mk_logins'})
ok: [rhl1] => (item={u'dest': u'/usr/lib/check_mk_agent/plugins', u'src': u'symantec_av'})




but if I use variable  for path "/usr/lib/check_mk_agent/plugins" then ansible always reports changed when I run ansible-playbook

variable in defaults/main.yml

plugins_dir: 'usr/lib/check_mk_agent/plugins'



- name: install plugins
  copy:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
    mode: 0755
    owner: root
    group: root
  with_items:
    - { src: mk_logins,dest: plugins_dir }
    - { src: symantec_av,dest: plugins_dir }




TASK [check-mk-agent : install plugins] ***********************************************************************************
changed: [rhl1] => (item={u'dest': u'plugins_dir', u'src': u'mk_logins'})
changed: [rhl1] => (item={u'dest': u'plugins_dir', u'src': u'symantec_av'})


So question is why is this happen? 

Thanks

Kai Stian Olstad

unread,
Oct 19, 2018, 4:46:09 AM10/19/18
to ansible...@googlegroups.com
On 19.10.2018 10:03, Jost wrote:
> variable in defaults/main.yml
>
> plugins_dir: 'usr/lib/check_mk_agent/plugins'
>
>
>
> - name: install plugins
> copy:
> src: "{{ item.src }}"
> dest: "{{ item.dest }}"
> mode: 0755
> owner: root
> group: root
> with_items:
> - { src: mk_logins,dest: plugins_dir }
> - { src: symantec_av,dest: plugins_dir }

Your plugins_dir in these two last line is not a variable since it's
missing {{ }} around them so they are literally the string plugins_dir.


> TASK [check-mk-agent : install plugins]
> ***********************************************************************************
> changed: [rhl1] => (item={u'dest': u'plugins_dir', u'src':
> u'mk_logins'})
> changed: [rhl1] => (item={u'dest': u'plugins_dir', u'src':
> u'symantec_av'})

As you can see here dest contains 'plugins_dir' and not the content of
the variable plugins_dir.

--
Kai Stian Olstad

Jost

unread,
Oct 19, 2018, 5:00:48 AM10/19/18
to Ansible Project
Thanks it works now.
Reply all
Reply to author
Forward
0 new messages