Comparing checksums on a group of files

10 skatījumi
Pāriet uz pirmo nelasīto ziņojumu

Hank Beatty

nelasīta,
2018. gada 10. apr. 10:35:5010.04.18
uz Ansible Project

Hello,

I would like to compare checksums on a group of files and then copy the new file over the old file if different.

Here is what I have so far:

- name: Get Checksum for Old Comparison Zone Files
  stat:
    path: "{{ named_options.directory }}/.{{ item.file }}.old"
  register: named_old_zones_stat
  with_items: "{{ named_zones | default([]) }}"

- debug:
    var: named_old_zones_stat

- name: Create New Comparison Zone Files
  template:
    src: zone_hidden.j2
    dest: "{{ named_options.directory }}/.{{ item.file }}.new"
  with_items: "{{ named_zones | default([]) }}"

- name: Get Checksum for New Comparison Zone Files
  stat:
    path: "{{ named_options.directory }}/.{{ item.file }}.new"
  register: named_new_zones_stat
  with_items: "{{ named_zones | default([]) }}"

- name: Copy the New Comparison Zones Over Old if Different
  template:
    src: zone_hidden.j2
    dest: "{{ named_options.directory }}/.{{ item.file }}.old"
  with_items: "{{ named_zones | default([]) }}"
  when:

The last task is where I am stumbling. I was thinking of using "with_nested" in the last task, but I cannot seem to make it work. Does anyone have any suggestions?

Thanks,
Hank

Brian Coca

nelasīta,
2018. gada 13. sept. 19:29:3013.09.18
uz Ansible Project
The template and copy modules do this automatically, files are only
copied if different.

--
----------
Brian Coca
Atbildēt visiem
Atbildēt autoram
Pārsūtīt
0 jauni ziņojumi