diff --git a/ansible.cfg b/ansible.cfg index 2fb444f..d9c18e0 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -1,3 +1,4 @@ [defaults] inventory_plugins = ./inventory_plugins callbacks_enabled = timer +interpreter_python = auto_silent diff --git a/update-ssh-config-file.yml b/update-ssh-config-file.yml index 29a8276..742e61d 100644 --- a/update-ssh-config-file.yml +++ b/update-ssh-config-file.yml @@ -6,7 +6,7 @@ # username := the default username to use for the ssh connection ############################################################# -# Updating ssh config for servers with given stage +# Creating inventory dynamically for given parameters ############################################################# - hosts: localhost @@ -21,6 +21,24 @@ - ansible_version.minor >= 10 msg: "The ansible version has to be at least ({{ ansible_version.full }})" +# add fictive server to load stage specific variables + - name: "Add <{{ stage }}-virtual-smardigo-host> to hosts" + add_host: + name: "{{ stage }}-virtual-smardigo-host" + groups: + - "stage_{{ stage }}" + changed_when: False + +############################################################# +# Updating ssh config for servers with given stage +############################################################# + +- hosts: "{{ stage }}-virtual-smardigo-host" + serial: "{{ serial_number | default(1) }}" + gather_facts: false + connection: local + + pre_tasks: - name: "Reading current server groups from hetzner" include_role: name: hcloud @@ -46,4 +64,4 @@ Host {{ host.name }} HostName {{ host.ip }} User {{ username }} - {% endfor %} \ No newline at end of file + {% endfor %}