├── LICENSE ├── README.md ├── defaults └── main.yml ├── files └── helper │ └── reboot-soon.sh ├── meta └── main.yml └── tasks └── main.yml /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Darek Owczarek 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Rolling Reboot Playbook 2 | ======== 3 | 4 | The [dareko.rolling_reboot](https://galaxy.ansibleworks.com/list#/roles/424) playbook performs servers reboot in rolling manner. 5 | 6 | Requirements 7 | ------------ 8 | 9 | This role requires Ansible 1.4 or higher. 10 | Platform requirements are listed in the Supported Platforms section of the role details. 11 | 12 | Role Variables 13 | -------------- 14 | 15 | The variables that can be passed to this role with default values are as follows. 16 | 17 | # number of seconds to wait before next server reboot 18 | rolling_reboot_pause: 60 19 | 20 | # by default wait for ssh daemon after reboot 21 | # listen to a service port that is meaningful in your environment 22 | # thus allowing you to reduce the value for rolling_reboot_pause 23 | rolling_reboot_wait_port: 22 24 | 25 | # number of seconds to wait before polling port 26 | # in some environments that can be set rather low (10 seconds or less) 27 | rolling_reboot_wait_delay: 60 28 | 29 | Dependencies 30 | ------------ 31 | 32 | None 33 | 34 | Example Playbook 35 | ---------------- 36 | 37 | 1. Add a group to the `hosts` inventory file 38 | 39 | 2. Add dareko.rolling.reboot role to the rolling_reboot.yml playbook 40 | 41 | - hosts: "{{ rolling_reboot_group }}" 42 | sudo: true 43 | serial: 1 44 | roles: 45 | - role: dareko.rolling_reboot 46 | 47 | 3. Execute the the playbook 48 | 49 | ansible-playbook -i hosts rolling_reboot.yml -e 'rolling_reboot_group= \ 50 | rolling_reboot_wait_port=8087 \ 51 | rolling_reboot_wait_delay=10 \ 52 | rolling_reboot_pause=10 ' 53 | 54 | License 55 | ------- 56 | 57 | [MIT License](http://choosealicense.com/licenses/mit/) 58 | 59 | Author Information 60 | ------------------ 61 | 62 | [Darek Owczarek](https://galaxy.ansibleworks.com/list#/users/1102) 63 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for ansible-rolling-reboot playbook 3 | 4 | # number of seconds to wait before next server reboot 5 | rolling_reboot_pause: 60 6 | 7 | # by default wait for ssh daemon after reboot 8 | rolling_reboot_wait_port: 22 9 | 10 | # wait 60 seconds before starting to poll 11 | rolling_reboot_wait_delay: 60 12 | -------------------------------------------------------------------------------- /files/helper/reboot-soon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -i 2 | 3 | ( ( sleep 5 ; /sbin/reboot --force --reboot ) & ) & 4 | [ "$0" == "/tmp/reboot-soon.sh" ] && rm -f /tmp/reboot-soon.sh 5 | 6 | 7 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: Dariusz Owczarek 4 | description: Playbook for servers reboot in rolling manner 5 | company: Sabre Inc. 6 | license: MIT 7 | min_ansible_version: 1.4 8 | platforms: 9 | - name: EL 10 | versions: 11 | - all 12 | - name: GenericUNIX 13 | versions: 14 | - all 15 | - name: Fedora 16 | versions: 17 | - all 18 | - name: opensuse 19 | versions: 20 | - all 21 | - name: GenericBSD 22 | versions: 23 | - all 24 | - name: FreeBSD 25 | versions: 26 | - all 27 | - name: Ubuntu 28 | versions: 29 | - all 30 | - name: SLES 31 | versions: 32 | - all 33 | - name: GenericLinux 34 | versions: 35 | - all 36 | - name: Debian 37 | versions: 38 | - all 39 | - name: Amazon 40 | versions: 41 | - all 42 | categories: 43 | - system 44 | dependencies: [] 45 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This role conains tasks for servers reboot in rolling manner 3 | 4 | - name: copy helper script 5 | copy: src=helper/reboot-soon.sh dest=/tmp/reboot-soon.sh mode=755 6 | 7 | - name: rebooting server 8 | command: /tmp/reboot-soon.sh & 9 | tags: reboot 10 | 11 | - name: waiting for port after reboot 12 | wait_for: host={{ inventory_hostname }} port={{ rolling_reboot_wait_port }} delay={{ rolling_reboot_wait_delay }} state=started 13 | connection: local 14 | sudo: false 15 | tags: reboot 16 | 17 | - name: pausing 18 | pause: seconds={{ rolling_reboot_pause }} 19 | tags: reboot 20 | --------------------------------------------------------------------------------