override hosts, add reboot if required
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
---
|
||||
- name: update apt-cache and upgrade
|
||||
hosts: oracle
|
||||
become: yes
|
||||
# 'all' is okay here, because the fail task will force the user to specify a limit on the command line, using -l or --limit
|
||||
hosts: all
|
||||
tasks:
|
||||
- name: checking limit arg
|
||||
fail:
|
||||
msg: "you must use -l or --limit - when you really want to use all hosts, use -l 'all'"
|
||||
when: ansible_limit is not defined
|
||||
run_once: true
|
||||
|
||||
- name: apt
|
||||
become: true
|
||||
apt:
|
||||
update_cache: yes
|
||||
upgrade: 'yes'
|
||||
|
||||
21
playbooks/rebootRequired.yml
Normal file
21
playbooks/rebootRequired.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
- name: reboot machine if required
|
||||
# 'all' is okay here, because the fail task will force the user to specify a limit on the command line, using -l or --limit
|
||||
hosts: 'all'
|
||||
|
||||
tasks:
|
||||
- name: checking limit arg
|
||||
fail:
|
||||
msg: "you must use -l or --limit - when you really want to use all hosts, use -l 'all'"
|
||||
when: ansible_limit is not defined
|
||||
run_once: true
|
||||
|
||||
- name: Check if reboot is required
|
||||
stat:
|
||||
path: /var/run/reboot-required
|
||||
register: reboot_required_file
|
||||
|
||||
- name: Reboot if required
|
||||
become: true
|
||||
reboot:
|
||||
when: reboot_required_file.stat.exists == true
|
||||
Reference in New Issue
Block a user