From d90144d2190009f8bd121cb8f773a9209500f034 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 1 Jan 2022 20:19:56 +0100 Subject: in-place variable cooking --- roles/cloud/install/tasks/hcloud.yml | 10 +++++----- roles/cloud/install/tasks/hroot.yml | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'roles/cloud/install/tasks') diff --git a/roles/cloud/install/tasks/hcloud.yml b/roles/cloud/install/tasks/hcloud.yml index b716f4ac..cd46d348 100644 --- a/roles/cloud/install/tasks/hcloud.yml +++ b/roles/cloud/install/tasks/hcloud.yml @@ -6,7 +6,7 @@ url: "https://api.hetzner.cloud/v1/ssh_keys" method: GET headers: - Authorization: "Bearer {{ install_cooked.cloud.credentials.token }}" + Authorization: "Bearer {{ install.cloud.credentials.token }}" status_code: 200 register: sshkeys @@ -14,10 +14,10 @@ delegate_to: localhost check_mode: no uri: - url: "https://api.hetzner.cloud/v1/servers?name={{ install_cooked.cloud.server_name | default(inventory_hostname) }}" + url: "https://api.hetzner.cloud/v1/servers?name={{ install.cloud.server_name | default(inventory_hostname) }}" method: GET headers: - Authorization: "Bearer {{ install_cooked.cloud.credentials.token }}" + Authorization: "Bearer {{ install.cloud.credentials.token }}" status_code: 200 register: serverstatus @@ -48,7 +48,7 @@ method: POST body: "{{ {'type': 'linux64', 'ssh_keys': (sshkeys.json.ssh_keys | map(attribute='id') | list) } | to_nice_json }}" headers: - Authorization: "Bearer {{ install_cooked.cloud.credentials.token }}" + Authorization: "Bearer {{ install.cloud.credentials.token }}" Content-Type: "application/json" status_code: 201 @@ -62,7 +62,7 @@ url: "https://api.hetzner.cloud/v1/servers/{{ serverstatus.json.servers[0].id }}/actions/reset" method: POST headers: - Authorization: "Bearer {{ install_cooked.cloud.credentials.token }}" + Authorization: "Bearer {{ install.cloud.credentials.token }}" status_code: 201 ### TODO: would be nice to get the SSH host key from robot diff --git a/roles/cloud/install/tasks/hroot.yml b/roles/cloud/install/tasks/hroot.yml index 1ff4a55d..588ae981 100644 --- a/roles/cloud/install/tasks/hroot.yml +++ b/roles/cloud/install/tasks/hroot.yml @@ -5,8 +5,8 @@ uri: url: "https://robot-ws.your-server.de/key" method: GET - user: "{{ install_cooked.cloud.credentials.username }}" - password: "{{ install_cooked.cloud.credentials.password }}" + user: "{{ install.cloud.credentials.username }}" + password: "{{ install.cloud.credentials.password }}" force_basic_auth: yes status_code: 200 register: sshkeys @@ -19,15 +19,15 @@ uri: url: "https://robot-ws.your-server.de/server" method: GET - user: "{{ install_cooked.cloud.credentials.username }}" - password: "{{ install_cooked.cloud.credentials.password }}" + user: "{{ install.cloud.credentials.username }}" + password: "{{ install.cloud.credentials.password }}" force_basic_auth: yes status_code: 200 register: servers - name: extract server IP address from robot result set_fact: - hetzner_main_ip: "{{ servers.json | hroot_extract_serverip(install_cooked.cloud.server_name | default(inventory_hostname)) }}" + hetzner_main_ip: "{{ servers.json | hroot_extract_serverip(install.cloud.server_name | default(inventory_hostname)) }}" - name: do not continue in check mode when: ansible_check_mode | bool @@ -48,8 +48,8 @@ uri: url: "https://robot-ws.your-server.de/boot/{{ hetzner_main_ip }}/rescue" method: GET - user: "{{ install_cooked.cloud.credentials.username }}" - password: "{{ install_cooked.cloud.credentials.password }}" + user: "{{ install.cloud.credentials.username }}" + password: "{{ install.cloud.credentials.password }}" force_basic_auth: yes status_code: 200 register: rescuestatus @@ -61,8 +61,8 @@ uri: url: "https://robot-ws.your-server.de/boot/{{ hetzner_main_ip }}/rescue" method: POST - user: "{{ install_cooked.cloud.credentials.username }}" - password: "{{ install_cooked.cloud.credentials.password }}" + user: "{{ install.cloud.credentials.username }}" + password: "{{ install.cloud.credentials.password }}" force_basic_auth: yes body: "os=linux&arch=64&authorized_key[]={{ sshkeys.json | hroot_extract_ssh_key_fingerprints | join('&authorized_key[]=') }}" status_code: 200 @@ -78,8 +78,8 @@ uri: url: "https://robot-ws.your-server.de/reset/{{ hetzner_main_ip }}" method: POST - user: "{{ install_cooked.cloud.credentials.username }}" - password: "{{ install_cooked.cloud.credentials.password }}" + user: "{{ install.cloud.credentials.username }}" + password: "{{ install.cloud.credentials.password }}" force_basic_auth: yes body: "type=hw" ## type=sw -> CTRL-ALT-DEL, type=hw -> reset button status_code: 200 -- cgit v1.2.3