Skip to content

Instantly share code, notes, and snippets.

@fia5000
Last active May 29, 2018 20:45
Show Gist options
  • Save fia5000/f9c599716c526f000af82a5a198f6244 to your computer and use it in GitHub Desktop.
Save fia5000/f9c599716c526f000af82a5a198f6244 to your computer and use it in GitHub Desktop.
v2 Inventory
[DEV_CPE_SERVERS]
DEV_CPE_NODE_1 ansible_host=x.x.x.x
[TEST_CPE_SERVERS]
TEST_CPE_NODE_1 ansible_host=x.x.x.x
[RUN_CPE_SERVERS]
RUN_CPE_NODE_1 ansible_host=x.x.x.x
RUN_CPE_NODE_2 ansible_host=x.x.x.x
[DEV_ICN_SERVERS]
DEV_ICN_NODE_1 ansible_host=x.x.x.x
[TEST_ICN_SERVERS]
TEST_ICN_NODE_1 ansible_host=x.x.x.x
[RUN_ICN_SERVERS]
RUN_ICN_NODE_1 ansible_host=x.x.x.x
RUN_ICN_NODE_2 ansible_host=x.x.x.x
[DEV_DB2_SERVERS]
DEV_DB2_NODE_1 ansible_host=x.x.x.x
DEV_DB2_NODE_1 ansible_host=x.x.x.x
DEV_DB2_AUX_NODE_1 ansible_host=x.x.x.x
DEV_DB2_AUX_NODE_2 ansible_host=x.x.x.x
[RUN_DB2_SERVERS]
RUN_DB2_NODE_1 ansible_host=x.x.x.x
RUN_DB2_NODE_1 ansible_host=x.x.x.x
RUN_DB2_AUX_NODE_1 ansible_host=x.x.x.x
RUN_DB2_AUX_NODE_2 ansible_host=x.x.x.x
[RUN_BJ_SERVERS]
BJ_NODE_1 ansible_host=x.x.x.x
BJ_NODE_2 ansible_host=x.x.x.x
[RUN_SDS_SERVERS]
RUN_SDS_NODE_1 ansible_host=x.x.x.x
[RUN_CPE_SERVERS]
RUN_CPE_NODE_1 ansible_host=x.x.x.x
[RUN_ICN_SERVERS]
RUN_ICN_NODE_1 ansible_host=x.x.x.x
[RUN_DB2_SERVERS]
RUN_DB2_NODE_1 ansible_host=x.x.x.x
[RUN_BJ_SERVERS]
RUN_BJ_NODE_1 ansible_host=x.x.x.x
[RUN_SDS_SERVERS]
RUN_SDS_NODE_1 ansible_host=x.x.x.x
@fia5000
Copy link
Author

fia5000 commented May 29, 2018

The idea is that the Inventory and host name will have a prefix for the environment it is meant for:

  • Therefore, tasks and roles can be targeted to specific subsets of these groups with limiters like when: "{{ env | upper}}_CPE_SERVERS in group_names" or when: "{{ env | upper }}_CPE_NODE_1 in inventory_hostnames"

env itself can be set by various means. We can either pass an extra variable at the time of playbook execution (likely the cleanest), or as an environment variable.... OR within a playbook, we can set_fact like so:

   - name: Create CPE Container Host List
     set_fact:
      env: {{'RUN' if OFFERING_TIER == "EXPRESS_RUN" else 'DEV' if ,....}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment