53 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
		
		
			
		
	
	
			53 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
| 
								 | 
							
								---
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- hosts: "{{ targets | default('managed') }}"
							 | 
						||
| 
								 | 
							
								  become: true
							 | 
						||
| 
								 | 
							
								  tasks:
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								      - name: Verify IP
							 | 
						||
| 
								 | 
							
								        ignore_errors: true
							 | 
						||
| 
								 | 
							
								        register: status
							 | 
						||
| 
								 | 
							
								        assert:
							 | 
						||
| 
								 | 
							
								          that:
							 | 
						||
| 
								 | 
							
								            - "ip in ansible_default_ipv4.address"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								      - debug:
							 | 
						||
| 
								 | 
							
								          msg: "Inventory IP {{ ip }} for {{ inventory_hostname }} doesn't match configured {{ ansible_default_ipv4.address }}"
							 | 
						||
| 
								 | 
							
								        when: status.failed
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								      - name: Verify MAC
							 | 
						||
| 
								 | 
							
								        ignore_errors: true
							 | 
						||
| 
								 | 
							
								        register: status
							 | 
						||
| 
								 | 
							
								        assert:
							 | 
						||
| 
								 | 
							
								          that:
							 | 
						||
| 
								 | 
							
								            - "mac in ansible_default_ipv4.macaddress"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								      - debug:
							 | 
						||
| 
								 | 
							
								          msg: "Inventory MAC {{ mac }} for {{ inventory_hostname }} doesn't match configured {{ ansible_default_ipv4.macaddress }}"
							 | 
						||
| 
								 | 
							
								        when: status.failed
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								      - name: Verify cores
							 | 
						||
| 
								 | 
							
								        ignore_errors: true
							 | 
						||
| 
								 | 
							
								        when: cores is defined
							 | 
						||
| 
								 | 
							
								        register: corescheck
							 | 
						||
| 
								 | 
							
								        assert:
							 | 
						||
| 
								 | 
							
								          that:
							 | 
						||
| 
								 | 
							
								            - "cores == ansible_processor_cores"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								      - debug:
							 | 
						||
| 
								 | 
							
								          msg: "Inventory {{ cores }} cores for {{ inventory_hostname }} doesn't match configured {{ ansible_processor_cores }}"
							 | 
						||
| 
								 | 
							
								        when: cores is defined and corescheck.failed
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								      - name: Verify memory
							 | 
						||
| 
								 | 
							
								        ignore_errors: true
							 | 
						||
| 
								 | 
							
								        register: memcheck
							 | 
						||
| 
								 | 
							
								        when: memory is defined
							 | 
						||
| 
								 | 
							
								        assert:
							 | 
						||
| 
								 | 
							
								          that:
							 | 
						||
| 
								 | 
							
								            - "memory == (ansible_memtotal_mb - ansible_memtotal_mb % 1000)/ 1000 + 1 " # hasty rounding
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								      - debug:
							 | 
						||
| 
								 | 
							
								          msg: "Inventory {{ memory }} GB memory for {{ inventory_hostname }} doesn't match configured {{ (ansible_memtotal_mb - ansible_memtotal_mb % 1000)/ 1000 + 1 }} GB"
							 | 
						||
| 
								 | 
							
								        when: memory is defined and memcheck.failed
							 |