From e9ad10429e45c6c7a3060cd9bb24746bfc2300ce Mon Sep 17 00:00:00 2001 From: pgrondek Date: Fri, 10 Apr 2020 21:38:37 +0200 Subject: [PATCH] add docker playbooks --- docker/ntpdate.yml | 14 ++++++++++++++ docker/reboot.yml | 36 ++++++++++++++++++++++++++++++++++++ hosts | 6 +++--- 3 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 docker/ntpdate.yml create mode 100644 docker/reboot.yml diff --git a/docker/ntpdate.yml b/docker/ntpdate.yml new file mode 100644 index 0000000..8462132 --- /dev/null +++ b/docker/ntpdate.yml @@ -0,0 +1,14 @@ +--- +- name: update date + hosts: docker_swarm + become_method: sudo + become_user: root + become: yes + + tasks: + - name: update datetime via ntpdate + shell: + cmd: | + ntpdate 192.168.50.3 + args: + executable: /bin/bash \ No newline at end of file diff --git a/docker/reboot.yml b/docker/reboot.yml new file mode 100644 index 0000000..551b39d --- /dev/null +++ b/docker/reboot.yml @@ -0,0 +1,36 @@ +--- +- name: reboot nodes + hosts: docker_swarm + become_method: sudo + become_user: root + become: yes + serial: 1 + + tasks: + - name: drain docker swarm + shell: + cmd: | + docker node update {{ docker_node }} --availability drain + sleep 30 + + - name: reboot + reboot: + msg: "Rebooting" + connect_timeout: 5 + reboot_timeout: 600 + pre_reboot_delay: 0 + post_reboot_delay: 30 + test_command: whoami + + - name: update datetime via ntpdate + shell: + cmd: | + ntpdate 192.168.50.3 + args: + executable: /bin/bash + + - name: drain docker swarm + shell: + cmd: | + docker node update {{ docker_node }} --availability active + sleep 30 diff --git a/hosts b/hosts index 418d8e0..174557a 100644 --- a/hosts +++ b/hosts @@ -5,6 +5,6 @@ prusa.lan ansible_user=ubuntu iron-man.lan [docker_swarm] -node-01.lan -node-02.lan -node-03.lan \ No newline at end of file +node-01.lan docker_node=node-01 +node-02.lan docker_node=node-02 +node-03.lan docker_node=node-03 \ No newline at end of file