From af1dd8e6e7f88bf999455cdd3510ec584210ef02 Mon Sep 17 00:00:00 2001 From: Vladimir Titov Date: Sat, 4 Aug 2018 15:07:22 +0500 Subject: [PATCH 1/9] More platform independent setup Run `apt-get update` only for Debian and Ubuntu platforms Install python using platform agnostic package module --- tasks/installimage.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks/installimage.yml b/tasks/installimage.yml index b0b5540..da582ce 100644 --- a/tasks/installimage.yml +++ b/tasks/installimage.yml @@ -36,9 +36,10 @@ - name: update apt raw: apt-get update + when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - name: install python on remote host - raw: apt-get install python -y + package: python - name: generate hostcode set_fact: From 27936569a6e44702ad79c62b2ce21335cadce9cb Mon Sep 17 00:00:00 2001 From: someone Date: Sat, 4 Aug 2018 15:28:55 +0500 Subject: [PATCH 2/9] Fix parameters for package module --- tasks/installimage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/installimage.yml b/tasks/installimage.yml index da582ce..c8fecbd 100644 --- a/tasks/installimage.yml +++ b/tasks/installimage.yml @@ -39,7 +39,7 @@ when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - name: install python on remote host - package: python + package: name=python state=present - name: generate hostcode set_fact: From c2daa396f6864607586b5d552c019aa17734b9fc Mon Sep 17 00:00:00 2001 From: someone Date: Fri, 10 Aug 2018 13:44:09 +0500 Subject: [PATCH 3/9] Regather facts after installimage and reboot --- tasks/installimage.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tasks/installimage.yml b/tasks/installimage.yml index c8fecbd..4bd95d8 100644 --- a/tasks/installimage.yml +++ b/tasks/installimage.yml @@ -34,6 +34,9 @@ delay=1 timeout=180 +- name: do facts module to get latest information + setup: + - name: update apt raw: apt-get update when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' From 650e94f88a663f450a405cf161dd1502b17bd284 Mon Sep 17 00:00:00 2001 From: someone Date: Fri, 17 Aug 2018 14:30:12 +0500 Subject: [PATCH 4/9] Configurable timeout after reboot --- defaults/main.yml | 1 + tasks/installimage.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 6da7c10..f20df11 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -15,4 +15,5 @@ hetzner_installimage_install_partitions: hetzner_installimage_install_image: /root/.oldroot/nfs/images/Debian-87-jessie-64-minimal.tar.gz # prevent reinstallation of running servers with /etc/hostcode file hetzner_installimage_ignore_hostcode: False +hetzner_installimage_after_reboot_timeout: 180 ... diff --git a/tasks/installimage.yml b/tasks/installimage.yml index 4bd95d8..55b11f1 100644 --- a/tasks/installimage.yml +++ b/tasks/installimage.yml @@ -32,7 +32,7 @@ host={{ ansible_host }} port=22 delay=1 - timeout=180 + timeout={{ hetzner_installimage_after_reboot_timeout }} - name: do facts module to get latest information setup: From b40c9dfc20c664e65b248ce924cc572ee300e383 Mon Sep 17 00:00:00 2001 From: someone Date: Fri, 17 Aug 2018 17:13:35 +0500 Subject: [PATCH 5/9] Ensure ssh port in rescue mode is always 22 --- tasks/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 87a0b21..2f6c293 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -52,5 +52,6 @@ - name: include installimage include: installimage.yml when: hetzner_installimage_run and hetzner_installimage_rescue.json.rescue.active == false and not ansible_check_mode - + vars: + ansible_port: 22 ... From 05353eb1d88e152520bb0321744ea42822e61219 Mon Sep 17 00:00:00 2001 From: someone Date: Sat, 18 Aug 2018 00:07:05 +0500 Subject: [PATCH 6/9] Ignore errors when removing servers from local known hosts file --- tasks/rescuemode.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/rescuemode.yml b/tasks/rescuemode.yml index 77b8f33..bb5971f 100644 --- a/tasks/rescuemode.yml +++ b/tasks/rescuemode.yml @@ -27,6 +27,7 @@ - name: remove server from local known_hosts file local_action: shell ssh-keygen -R {{ ansible_host }} + ignore_errors: true - name: pause a bit for the hardware reset to kick in pause: seconds=15 From bc9c61e5d7f6af33ce7a9feea7ac92c507d96a58 Mon Sep 17 00:00:00 2001 From: Vladimir Titov Date: Mon, 10 Dec 2018 22:44:43 +0200 Subject: [PATCH 7/9] Update installimage.yml --- tasks/installimage.yml | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/tasks/installimage.yml b/tasks/installimage.yml index 55b11f1..a2a3d8c 100644 --- a/tasks/installimage.yml +++ b/tasks/installimage.yml @@ -16,24 +16,12 @@ register: result - name: reboot server - command: reboot - async: 0 - poll: 0 - ignore_errors: true + reboot: + reboot_timeout: '{{ hetzner_installimage_after_reboot_timeout }}' - name: remove server from local known_hosts file local_action: shell ssh-keygen -R {{ ansible_host }} -- name: pause a bit for the reboot to kick in - pause: seconds=60 - -- name: waiting for server to come back - local_action: wait_for - host={{ ansible_host }} - port=22 - delay=1 - timeout={{ hetzner_installimage_after_reboot_timeout }} - - name: do facts module to get latest information setup: From ae913050a13746f7352553e3459659db10d49d94 Mon Sep 17 00:00:00 2001 From: Vladimir Titov Date: Mon, 10 Dec 2018 22:45:12 +0200 Subject: [PATCH 8/9] Update main.yml --- defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index f20df11..ff28df8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -15,5 +15,5 @@ hetzner_installimage_install_partitions: hetzner_installimage_install_image: /root/.oldroot/nfs/images/Debian-87-jessie-64-minimal.tar.gz # prevent reinstallation of running servers with /etc/hostcode file hetzner_installimage_ignore_hostcode: False -hetzner_installimage_after_reboot_timeout: 180 +hetzner_installimage_after_reboot_timeout: 500 ... From e855ebdba69b75ac3ddcc74c8c46b56e4733a628 Mon Sep 17 00:00:00 2001 From: Vladimir Titov Date: Mon, 14 Jan 2019 23:14:32 +0200 Subject: [PATCH 9/9] Update installimage.yml --- tasks/installimage.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tasks/installimage.yml b/tasks/installimage.yml index a2a3d8c..25682be 100644 --- a/tasks/installimage.yml +++ b/tasks/installimage.yml @@ -25,13 +25,6 @@ - name: do facts module to get latest information setup: -- name: update apt - raw: apt-get update - when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: install python on remote host - package: name=python state=present - - name: generate hostcode set_fact: _hostcode: "{{ ansible_host | md5 }}"