Clever. Does it create 99 local directories, or just the next number that 
doesn't exist?

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Jan 27, 2023, at 10:23 AM, javed khan Siddque <[email protected]> 
wrote:

I tried 2-3 combination , but nothing worked , So i thought of asking here , 
Since my issue fix from here only.
Then i found the solution by small research on jinja and dict register output



- name: "Register a Variable and Search to perform Operation"
  hosts: localhost
  vars:
    list_of_sequence: "{{ range(1, 100) | list }}"
  tasks:
    - name: Create a series of directories with even numbers for some reason
      ansible.builtin.file:
        path: "/var/test{{ '%02d' | format(item) }}"
        state: directory
        mode: '0655'
      become: true
      register: res
      when: not (res.changed | d(false))
       loop: '{{ list_of_sequence }}'


On Friday, January 27, 2023 at 7:06:19 PM UTC+5:30 [email protected] wrote:
You are asking us to solve your problem. You aren't asking us a question about 
ansible itself.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123<tel:(202)%20355-4123>

On Jan 27, 2023, at 8:32 AM, javed khan Siddque <[email protected]> wrote:

i am looking for some concent like below

1) Look For /var/test01 , if not there create it- test01
2) Look For /var/test01 , if already exist then move to next name :- test02 
(move like next integer number)
3) Look for /var/test01 or 02 , then move to next name :- test03 (move like 
next integer number)
   and so on.


the below concept is not working


- name: "Register a Variable and Search to perform Operation"
  hosts: localhost
  tasks:
    - name: Create a series of directories with even numbers for some reason
      ansible.builtin.file:
        dest: "/var/test{{ '%02d' | format(item) }}"
        state: directory
        mode: '0655'
      become: true
      loop: "{{ range(0, 100) | list }}"

--
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/c364f32a-b419-4313-a9d5-8085384f658an%40googlegroups.com<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2Fc364f32a-b419-4313-a9d5-8085384f658an%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C814765379a7c4781ac0008db007a748a%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638104298191385900%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=sPDkxWIl%2FmkmNArUEQggNHeNnEsytLbnnekAEDM1sLA%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]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/56c4c0ac-541f-412f-a0de-c54b2fbb22ben%40googlegroups.com<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2F56c4c0ac-541f-412f-a0de-c54b2fbb22ben%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C814765379a7c4781ac0008db007a748a%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638104298191385900%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=JAVe6fl57TgKF8v4dHjsg7eTiJ0%2BxrfXGRFW87ZD4dM%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/0578B587-45F7-491F-83CF-77C619A64EB3%40nist.gov.

Reply via email to