Applying dot notation against lookup results in one command?

8 views
Skip to first unread message

Sam Sen

unread,
May 24, 2016, 2:26:18 PM5/24/16
to Ansible Project
Is there a way to apply dot notation against the 'environment_id' variable so that I do it once and not have to apply it multiple times within my file? What I really want is the value after I "grep" for the last two character in the string (see debug statement).

- name: Get environment id
  set_fact:
    environment_id: "{{ lookup('ini','environment section=multidb file=xyz.conf') }}"

- debug: msg={{ environment_id[-2:] }}

- name: Build list of modules
  set_fact:
    deploy_list: "{{ item | replace('deploys/' + environment_id  + '/','') }}-{{ lookup('consul_kv','deploys/' + environment_id + '/' + item) }}"
    with_items: "{{ modules }}"
    register: deploy_list_result
Reply all
Reply to author
Forward
0 new messages