Skip to content

Commit d72c2ad

Browse files
committed
creating meta groups that include environment specific groups, but with name minus 'group_suffix' set in dog.yml
1 parent 6640306 commit d72c2ad

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

.tool-versions

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
direnv 2.32.1
2-
python 3.7.5
1+
direnv 2.35.0
2+
python 3.11.11
3+
pipenv 2024.4.1

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ HOSTNAME=github.com
22
NAMESPACE=relaypro-open
33
NAME=community.dog
44
BINARY=${NAME}
5-
VERSION=1.0.4
5+
VERSION=1.0.5
66
OS_ARCH=linux_amd64
77

88
github_release:

Pipfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ verify_ssl = true
44
name = "pypi"
55

66
[packages]
7-
ansible = "2.13.6"
8-
api-client = {git = "https://github.com/Phonebooth/api-client.git"}
7+
ansible = "==8.7.0"
98
boto = "2.49.0"
109
boto3 = "1.26.13"
1110
botocore = "1.29.13"
1211
credstash = "1.17.1"
13-
dog-api-python = {git = "https://github.com/relaypro-open/dog_api_python.git"}
12+
dog-api-python = {editable = true, git = "https://github.com/relaypro-open/dog_api_python.git", ref = "6bd2cf07b6352030e0fae22891a9f7d6c08db81f"}
1413

1514
[dev-packages]
1615

1716
[requires]
18-
python_version = "3.7.5"
17+
python_version = "3.11.11"

galaxy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace: community
99
name: dog
10-
version: 1.0.4
10+
version: 1.0.5
1111
readme: README.md
1212
authors:
1313
- Drew Gulino

plugins/inventory/dog_inventory.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@
8585
- name of dog fact entry
8686
type: str
8787
required: false
88+
group_suffix:
89+
version_added: "1.0.5"
90+
description:
91+
- environment specific suffix at the end of group names. example group name = 'test_qa', group_suffix = '_qa'
92+
type: str
93+
required: false
8894
unique_id_key:
8995
description:
9096
- The key to be used as the server's name
@@ -203,6 +209,14 @@ def _populate(self, client):
203209
self.groups = dog_groups
204210

205211
for group_name, group in self.groups.items():
212+
#create another generic group and add environment specific group as child
213+
if re.fullmatch(r'.*' + self.group_suffix + '$', group_name):
214+
group_group_name = re.sub(r'' + self.group_suffix + '$', '', group_name)
215+
group_group = {
216+
"name": group_group_name,
217+
"children":[group_name]
218+
}
219+
self.parse_group(group_group_name, group_group)
206220
self.parse_group(group_name, group)
207221

208222
for host in hosts:
@@ -382,6 +396,7 @@ def verify_file(self, path):
382396
def _create_client(self):
383397
self.dog_env = self.get_option("dog_env")
384398
self.dog_fact = self.get_option("dog_fact")
399+
self.group_suffix = self.get_option("group_suffix")
385400
if self.dog_env is None:
386401
print("ERROR: dog_env opion not set in dog.yml")
387402
exit

0 commit comments

Comments
 (0)