ansible-playbook --check

Hello!

In one of playbooks i have template action with: 'owner=pgsql
group=pgsql mode=0400'.
Playbook has 'sudo: yes' declared and work properly.
But ansible-playbook called with '--check --diff' can't diff file, i
suupose this scenario executes without sudo calling, am i right?

I also tried to force apply command line sudo switch:
'ansible-playbook postgresql.yml --check --diff --sudo'
It does not work well :frowning:

Is it right behaviour or bug?

Thank you an advance!

Can you explain what "cannot diff file" means?

Any particular output you are seeing?

Can you explain what "cannot diff file" means?

Any particular output you are seeing?

Ok, i can demostrate real example.

From postgresql playbook:

- hosts: postgresql
  sudo: yes
  tasks:
    - name: create postgresql data directory
      # directory restrictive permissions required!
      file: path=${postgresql.datadir} state=directory owner=pgsql group=pgsql mode=0700
    - name: configure postgresql
      template: src=templates/postgresql/postgresql.conf dest=${postgresql.datadir}/ owner=pgsql group=pgsql mode=0444

Now play:

(ansible)[lonerr@neon ~/src]% ansible-playbook postgresql.yml
PLAY [postgresql] *********************
GATHERING FACTS *********************
ok: [db01]
TASK: [create postgresql data directory] *********************
ok: [db01]
TASK: [configure postgresql] *********************
ok: [db01] => (item=./templates/postgresql/postgresql.conf)
PLAY RECAP *********************
db01 : ok=3 changed=0 unreachable=0 failed=0

As you can see, file is in actual state, now run with '--check --diff':

(ansible)[lonerr@neon ~/src]% ansible-playbook postgresql.yml --check --diff
PLAY [postgresql] *********************
GATHERING FACTS *********************
ok: [db01]
TASK: [create postgresql data directory] *********************
ok: [db01]
TASK: [configure postgresql] *********************
changed: [db01] => (item=./templates/postgresql/postgresql.conf)
PLAY RECAP *********************
db01 : ok=3 changed=1 unreachable=0 failed=0

Do you feel the difference?

This is Ansible 1.1?

Output of ansible --version?

Maybe the file attributes required a change by the content was already correct?

This is Ansible 1.1?

Output of ansible --version?

Yes:
(ansible)[lonerr@neon ~/src/Leitung]% ansible --version
ansible 1.1

- hosts: postgresql
  sudo: yes
  tasks:
    - name: create postgresql data directory
      # directory restrictive permissions required!
      file: path=${postgresql.datadir} state=directory owner=pgsql group=pgsql mode=0700
    - name: configure postgresql
      template: src=templates/postgresql/postgresql.conf dest=${postgresql.datadir}/ owner=pgsql group=pgsql mode=0444

Template destination ned to be a file, try this:

template: src=templates/postgresql/postgresql.conf dest=${postgresql.datadir}/postgresql.conf owner=pgsql group=pgsql mode=0444

Bye
       Marco

​That's actually not true any more, in the very latest devel.​

> - hosts: postgresql
> sudo: yes
> tasks:
> - name: create postgresql data directory
> # directory restrictive permissions required!
> file: path=${postgresql.datadir} state=directory owner=pgsql group=pgsql mode=0700
> - name: configure postgresql
> template: src=templates/postgresql/postgresql.conf dest=${postgresql.datadir}/ owner=pgsql group=pgsql mode=0444

Template destination ned to be a file, try this:

> template: src=templates/postgresql/postgresql.conf dest=${postgresql.datadir}/postgresql.conf owner=pgsql group=pgsql mode=0444

The same result :frowning: