Skip to content

Commit f1d4813

Browse files
authored
Add GCP support to FreeIPA host group role (#61)
Signed-off-by: Jim Enright <[email protected]>
1 parent d333284 commit f1d4813

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

roles/freeipa_host_group/defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ freeipa_host_group__env_name: "{{ common__env_name }}"
2323
freeipa_host_group__infra_type: "{{ common__infra_type }}"
2424
freeipa_host_group__region: "{{ common__region }}"
2525

26+
freeipa_host_group__gcp_project: "{{ common__gcp_project }}"
27+
2628
# Outputs
2729
freeipa_host_group__host_group_name: "freeipa_server_hosts"

roles/freeipa_host_group/tasks/main.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,22 @@
4646
# when: freeipa_host_group__infra_type == "azure"
4747
# block:
4848

49-
# TODO: A block per cloud provider - GCP
5049
# Get instance details for specific infra_type - GCP
51-
# - name: Gather FreeIPA instance details on GCP
52-
# when: freeipa_host_group__infra_type == "gcp"
53-
# block:
50+
- name: Gather FreeIPA instance details on GCP
51+
when: freeipa_host_group__infra_type == "gcp"
52+
block:
53+
- name: Gather Address information used by FreeIPA GCP instance
54+
google.cloud.gcp_compute_address_info:
55+
region: "{{ freeipa_host_group__region }}"
56+
project: "{{ freeipa_host_group__gcp_project }}"
57+
# Filter on the freeipa instance name with the timestamp stripped
58+
filters:
59+
- "name : {{ __freeipa_server_instance_id | regex_replace('[^-]+$', '') }}*"
60+
register: __gcp_freeipa_address_info
61+
62+
- name: Set facts for the FreeIPA server IP
63+
ansible.builtin.set_fact:
64+
__freeipa_server_public_ip: "{{ __gcp_freeipa_address_info.resources | map(attribute='address') }}"
5465

5566
# Add the FreeIPA server and username to the inventory
5667
- name: Add FreeIPA servers to inventory

0 commit comments

Comments
 (0)