Commit c790dc1f authored by nanahira's avatar nanahira

improve reboot param

parent ea5e2ea3
- name: clean some Debian packages
become: true
apt:
name: ufw,iptables-persistent,needrestart,docker,docker-engine,docker.io,docker-io,docker-ee
state: absent
autoremove: yes
purge: yes
when: ansible_os_family == 'Debian'
- name: clean packages again
include_tasks: apt-clean.yml
- name: install aptitude first - name: install aptitude first
become: true become: true
apt: apt:
......
...@@ -17,6 +17,11 @@ ...@@ -17,6 +17,11 @@
name: linux-xanmod name: linux-xanmod
state: latest state: latest
update_cache: true update_cache: true
register: xanmod_result
- name: register reboot
set_fact:
manual_reboot: true
when: xanmod_result.changed
- name: install intel microcode - name: install intel microcode
become: true become: true
apt: apt:
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
regexp: '^#?PasswordAuthentication (true|yes).*$' regexp: '^#?PasswordAuthentication (true|yes).*$'
line: 'PasswordAuthentication no' line: 'PasswordAuthentication no'
backrefs: true backrefs: true
when: "(ansible_user_id == 'root' or ansible_user_id == 'nanahira' or ansible_user_id == 'mycard' or ansible_user_id == 'zh99998') and not allow_password" # Only self-managed servers when: "not allow_password"
notify: restart_sshd notify: restart_sshd
- name: permit root login - name: permit root login
lineinfile: lineinfile:
......
...@@ -38,18 +38,15 @@ ...@@ -38,18 +38,15 @@
- name: redhat configures before reboot - name: redhat configures before reboot
include_tasks: redhat_configures.yml include_tasks: redhat_configures.yml
when: ansible_os_family == 'RedHat' when: ansible_os_family == 'RedHat'
- name: 系统源 重启 - name: check reboot needed
stat:
path: /var/run/reboot-required
register: reboot_required_result
- name: reboot
become: true become: true
shell: reboot reboot:
async: 0 reboot_timeout: 600
poll: 0 when: reboot and (reboot_required_result.stat.exists or manual_reboot)
register: reboot_result
args:
removes: /var/run/reboot-required
when: reboot
- name: 系统源 重启等待
local_action: wait_for host={{ ansible_ssh_host }} state=started
when: reboot and reboot_result.changed
- name: 重新读取主机信息 - name: 重新读取主机信息
setup: setup:
when: reboot and reboot_result.changed when: reboot and reboot_result.changed
...@@ -102,14 +102,8 @@ ...@@ -102,14 +102,8 @@
- name: nvidia source - name: nvidia source
include_tasks: nvidia-source.yml include_tasks: nvidia-source.yml
when: nvidia_driver_version and ansible_os_family == 'Debian' when: nvidia_driver_version and ansible_os_family == 'Debian'
- name: clean some Debian packages - name: clean packages
become: true include_tasks: apt-clean.yml
apt:
name: ufw,iptables-persistent,needrestart,docker,docker-engine,docker.io,docker-io,docker-ee
state: absent
autoremove: yes
purge: yes
when: ansible_os_family == 'Debian'
- name: Debian laptop disable lid - name: Debian laptop disable lid
become: true become: true
blockinfile: blockinfile:
......
--- ---
# vars file for init # vars file for init
manual_reboot: false
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment