Skip to content

Commit b194b11

Browse files
committed
Better variable gathering, fixed empty DNS IP
1 parent dbe81cd commit b194b11

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

app/playbook.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
44

55
from __future__ import (absolute_import, division, print_function)
6+
67
__metaclass__ = type
78

89
import os
@@ -19,7 +20,6 @@
1920
from ansible.utils.collection_loader import set_collection_playbook_paths
2021
from ansible.plugins.loader import add_all_plugin_dirs
2122

22-
2323
display = Display()
2424

2525

@@ -187,12 +187,14 @@ def _process_block(b):
187187
display.display(taskmsg)
188188

189189
host = inventory.groups['vpn-host'].hosts[0].name
190-
fact_cache = pbex._variable_manager._nonpersistent_fact_cache[host]
190+
host_vars = variable_manager.get_vars()['hostvars'][host]
191191
return {
192-
'CA_password': fact_cache['CA_password'],
193-
'p12_export_password': fact_cache['p12_export_password'],
194-
'algo_server_name': variable_manager.extra_vars['server_name'],
195-
'ipv6_support': fact_cache['ipv6_support'],
196-
'local_service_ip': variable_manager.get_vars()['hostvars'][host]['ansible_lo']['ipv4_secondaries'][0]['address'],
192+
'CA_password': host_vars.get('CA_password'),
193+
'p12_export_password': host_vars.get('p12_export_password'),
194+
'algo_server_name': host_vars.get('server_name'),
195+
'ipv6_support': host_vars.get('ipv6_support'),
196+
'local_service_ip': host_vars.get('ansible_lo') and
197+
host_vars.get('ansible_lo').get('ipv4_secondaries') and
198+
host_vars.get('ansible_lo').get('ipv4_secondaries')[0]['address'],
197199
'ansible_ssh_host': host,
198200
}

0 commit comments

Comments
 (0)