diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..8647c5a --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,8 @@ +[defaults] +any_errors_fatal = True +deprecation_warnings = True +display_skipped_hosts = False +host_key_checking = False +nocows = 1 +remote_user = root +retry_files_enabled = False diff --git a/group_vars/k8s b/group_vars/k8s index b23c14f..b02bb36 100644 --- a/group_vars/k8s +++ b/group_vars/k8s @@ -1,6 +1,5 @@ --- -ansible_user: deploy -ansible_become: true +ansible_user: root ansible_port: 22 harden_linux_sshd_settings_user: diff --git a/scripts/scw_inventory.py b/scripts/scw_inventory.py index 151e38a..7ee9fd8 100755 --- a/scripts/scw_inventory.py +++ b/scripts/scw_inventory.py @@ -52,11 +52,17 @@ class SCWInventory(object): [i['name'], i['public_ip'], i['tags'], i['private_ip']] for i in result_par1['servers'] + result_ams1['servers'] ] for host, ip_info, tags, private_ip in self.inventory: - self.response['_meta']['hostvars'][host] = { - 'ansible_host': ip_info['address'] if ip_info else private_ip, - 'public_ip': ip_info['address'] if ip_info else None, - 'private_ip': private_ip + host_vars = { + 'private_ip': private_ip, + 'ansible_python_interpreter': '/usr/bin/python3' } + if ip_info: + host_vars['ansible_host'] = ip_info['address'] + host_vars['public_ip'] = ip_info['address'] + else: + host_vars['ansible_host'] = private_ip + + self.response['_meta']['hostvars'][host] = host_vars if tags: for tag in tags: self._add_to_response( @@ -64,6 +70,10 @@ class SCWInventory(object): host ) + for host, variables in self.response['_meta']['hostvars'].items(): + if host != 'proxy1': + variables['ansible_ssh_common_args'] = '-o ProxyCommand="ssh -W %h:%p -q root@' + self.response['_meta']['hostvars']['proxy1']['public_ip'] + '"' + def _add_to_response(self, group, hostname): ''' add a host to a group within the response