Last active
October 7, 2021 19:12
-
-
Save chrisjohnson/a27b64146250ceb60bf5fa7ee94a1c59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: "{{ host_pattern }}" | |
gather_facts: yes | |
become: yes | |
tasks: | |
- name: Determine namespace (with app_id) | |
set_fact: | |
consul_namespace: "{{ facter_app_env }}-{{ facter_app_id }}" | |
when: facter_app_id != '' | |
- name: Determine namespace (without app_id) | |
set_fact: | |
consul_namespace: "{{ facter_app_env }}" | |
when: facter_app_id == '' | |
- name: Append namespace to creation list | |
delegate_to: localhost | |
delegate_facts: true | |
set_fact: | |
namespaces_to_be_created: "{{ hostvars['localhost']['namespaces_to_be_created'] | default([]) | union([ consul_namespace ]) | unique }}" | |
when: namespace_check_response.status == 404 | |
- hosts: localhost | |
gather_facts: false | |
tasks: | |
- include_tasks: tasks/create-namespace.yml | |
vars: | |
consul_namespace: "{{ item }}" | |
with_items: "{{ namespaces_to_be_created | default([]) }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment