0

I tried to trim the custom facts but it will not give me expected result. My entire code as below.

---
  - name: Extarcting the Value
    hosts: localhost
    gather_facts: no
    connection: local
    vars: 
       app_brach: onkar-test
    vars_files:
       - common.yml
    tasks:
      - name: setting the facts
        set_fact: 
            app_name_list: "{{ app_name_list|default([])) + [item.name] }}'
        loop: "{{apps_to_deploy}}"
      - name: display information
        debug: 
          var: app_name_list
      - name: resetting the fact 
        set_fact: 
          app_name_list: "{{ item | reject('search', '{{app_branch'}} | list }}"
        loop: app_name_list
      - name: display new list
        debug: 
          var: app_name_list1

and my common.yml is as below.

---
apps_to_deploy:
   - name: jaw-app-worker-{{app_branch}}
     version: 1.0.0
   - name: jaw-pat-valid-{{app_branch}}
     version: 1.0.1

basically first I want to assign app_name_list with app_branch which is vriable and again need to reset app_name_list custome facts by removing app_branch variable.

β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
omankame
  • 59
  • 5
  • Does this answer your question? [How can I make Ansible interpret a variable inside a variable?](https://stackoverflow.com/questions/67408680/how-can-i-make-ansible-interpret-a-variable-inside-a-variable) – β.εηοιτ.βε Jul 18 '22 at 12:57
  • There are other obvious mistakes like `app_name_list: "{{ app_name_list|default([])) + [item.name] }}'` have unbalanced parenthesis, close with a single quote when it opens with a double. `app_name_list: "{{ item | reject('search', '{{app_branch'}} | list }}"` also have unbalanced parenthesis, ... Please see [mre] and [ask]. – β.εηοιτ.βε Jul 18 '22 at 13:00

0 Answers0