Skip to content

Commit

Permalink
Do not make ansible_connection unsafe.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Mar 13, 2024
1 parent 5435866 commit 6170c58
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions plugins/inventory/docker_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ def _populate(self, client):
if add_legacy_groups:
groups.append('service_{0}'.format(service_name))

ansible_connection = None
if connection_type == 'ssh':
# Figure out ssh IP and Port
try:
Expand All @@ -297,14 +298,14 @@ def _populate(self, client):
elif connection_type == 'docker-cli':
facts.update(dict(
ansible_host=full_name,
ansible_connection='community.docker.docker',
))
ansible_connection = 'community.docker.docker'
elif connection_type == 'docker-api':
facts.update(dict(
ansible_host=full_name,
ansible_connection='community.docker.docker_api',
))
facts.update(extra_facts)
ansible_connection = 'community.docker.docker_api'

full_facts.update(facts)
for key, value in inspect.items():
Expand All @@ -313,6 +314,11 @@ def _populate(self, client):

full_facts = make_unsafe(full_facts)

if ansible_connection:
for d in (facts, full_facts):
if 'ansible_connection' not in d:
d['ansible_connection'] = ansible_connection

if not filter_host(self, name, full_facts, filters):
continue

Expand Down

0 comments on commit 6170c58

Please sign in to comment.