Ansible describes a state. In your case you want a file to look a certain way. The task will compare the output of the derived template with the existing file. If the existing file matches, no change is made. If the existing file differs or does not exist, it is overwritten or created. You don't need the "force" param.
Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 > On Nov 10, 2022, at 8:41 AM, dulhaver via Ansible Project > <[email protected]> wrote: > > I need to repair some templated files from a previous playbook execution > > ##### this is a test ######################################### > > - name: my template TEST - template postgres.conf > vars: > - pg_service_name: "{{ item }}" > ansible.builtin.template: > src: 00-ina-default.conf.j2 # 10-pg-service.conf > dest: "/home/postgres/{{ pg_service_name }}/00-ina-default.conf" > owner: postgres > group: postgres > force: true > backup: true > mode: 0600 > become: true > loop: > - somedir > > ##### this was a test ######################################## > > this works whether dest does not exist. I want to overwrite an existing file > though. This file possibly is or is not identical. > > Can it be the force only works when the new and the old file differ? > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2F1890057150.554463.1668087697988%2540office.mailbox.org&data=05%7C01%7Cwalter.rowe%40nist.gov%7Ccb06f06277a84f7179a308dac3214f60%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638036845095155999%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=89Yh%2BMkgT0%2BB6aq8puog46RalpHHDCbMlfsGdbzYob4%3D&reserved=0. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/E1101E15-2062-410F-92BD-3CE85D5808D2%40nist.gov.
