Skip to content

Commit

Permalink
Add server rebooting (optionally) (fix #1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Mierzejewski committed Jan 7, 2015
1 parent 582e821 commit 285ac19
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,23 @@ Enter id_rsa.pub path [~/.ssh/id_rsa.pub]:
Add user to sudoers group (y/n) [n]: y
```


## Script execution

Finally, execute bootstrap Ansible task for admin user:

```
ansible-playbook bootstrap.yml --ask-sudo
$ ansible-playbook bootstrap.yml --ask-sudo
sudo password:
```

## Reboot

After successfully bootstrapping and securing your server, I recommend to reboot server for kernel updates.

```
$ ansible-playbook reboot.yml --ask-sudo
sudo password:
Are you sure you want to reboot server (yes/no)? [no]: yes
```

## Collectd
Expand Down
13 changes: 13 additions & 0 deletions reboot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Reboot server
hosts: server
sudo: yes
roles:
- reboot

vars_prompt:
- name: "reboot"
prompt: "Are you sure you want to reboot server (yes/no)?"
private: no
default: "no"

12 changes: 12 additions & 0 deletions roles/reboot/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: restart machine
command: shutdown -r now "Ansible updates triggered"
async: 0
poll: 0
ignore_errors: true
when: reboot == "yes"

- name: waiting for server to come back
sudo: False
local_action: wait_for host="{{ inventory_hostname }}" port=22 delay=1 timeout=300
when: reboot == "yes"

0 comments on commit 285ac19

Please sign in to comment.