On Mon, 12 Jun 2023 11:52:43 -0700 (PDT)
javed khan Siddque <[email protected]> wrote:

>   vars:
>     isilon_cluster_name_p: "server"
>     primary_data_center: "SSDC"
>     region: "SC"
>     division: "HOS"
>     app_id: "1234"
>     env: "D"
>     my_app_id: "{{ '{:>05}'.format(app_id) }}"
>     my_seq_id: "{{ '%02d' | format(item) }}"
>     list_of_sequence: "{{ range(1, 10) | list }}"
> ...
>     "msg": [
>         [
>             "/ifs/SSDC/server/HOSSCD0123401",
>             "/ifs/SSDC/server/HOSSCD0123402",
>             "/ifs/SSDC/server/HOSSCD0123403",
>             "/ifs/SSDC/server/HOSSCD0123404",
>             "/ifs/SSDC/server/HOSSCD0123405",
>             "/ifs/SSDC/server/HOSSCD0123406",
>             "/ifs/SSDC/server/HOSSCD0123407",
>             "/ifs/SSDC/server/HOSSCD0123408",
>             "/ifs/SSDC/server/HOSSCD0123409"
>         ]
>     ]

Given the variables for testing

  center: "SSDC"
  cluster: "server"
  division: "div"
  region: "reg"
  env: "env"
  app_id: "1234"
  list_of_sequence: "{{ range(1, 10) }}"

Declare *path*, *prefix*, and *app*. You have to convert *app_id*
from string to integer because you quotes the number

  path: "/ifs/{{ center }}/{{ cluster }}"
  prefix: "{{ division }}{{ region }}{{ env }}"
  app: "{{ '%05d' % (app_id|int) }}"

Use Jinja template to create the list

  my_list: |
    {% filter from_yaml %}
    {% for i in list_of_sequence %}
    - {{ path }}/{{ prefix|upper }}{{ app }}{{ '%02d' % (i) }}
    {% endfor %}
    {% endfilter %}

gives

  my_list:
  - /ifs/SSDC/server/DIVREGENV0123401
  - /ifs/SSDC/server/DIVREGENV0123402
  - /ifs/SSDC/server/DIVREGENV0123403
  - /ifs/SSDC/server/DIVREGENV0123404
  - /ifs/SSDC/server/DIVREGENV0123405
  - /ifs/SSDC/server/DIVREGENV0123406
  - /ifs/SSDC/server/DIVREGENV0123407
  - /ifs/SSDC/server/DIVREGENV0123408
  - /ifs/SSDC/server/DIVREGENV0123409


-- 
Vladimir Botka

-- 
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/20230613001138.21d21387%40gmail.com.

Attachment: pgpsHUtq_FCUS.pgp
Description: OpenPGP digital signature

Reply via email to