25 lines
		
	
	
		
			626 B
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			626 B
		
	
	
	
		
			YAML
		
	
	
	
	
	
| ---
 | |
| - name: Update system packages
 | |
|   hosts: gitrunner
 | |
|   become: yes
 | |
|   
 | |
|   tasks:
 | |
|     - name: Update system packages
 | |
|       yum:
 | |
|         name: "*"
 | |
|         state: latest
 | |
|         update_cache: yes  
 | |
|     
 | |
|     - name: Check if reboot required (RedHat/CentOS)
 | |
|       command: needs-restarting -r
 | |
|       register: needs_restarting_output
 | |
|       changed_when: false
 | |
|       ignore_errors: true
 | |
|       when: ansible_os_family == "RedHat"
 | |
|     
 | |
|     - name: Reboot if required (RedHat/CentOS)
 | |
|       reboot:
 | |
|       when: 
 | |
|         - ansible_os_family == "RedHat"
 | |
|         - needs_restarting_output.rc == 1
 | |
|         - needs_restarting_output is defined |