42 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
---
 | 
						|
- name: Host information
 | 
						|
  hosts: all
 | 
						|
  tasks:
 | 
						|
    - name: Print OS distribution and version
 | 
						|
      ansible.builtin.debug:
 | 
						|
        msg: "{{ ansible_facts['distribution'] }} {{ ansible_facts['distribution_version'] }} ({{ ansible_facts['distribution_release'] }})"
 | 
						|
 | 
						|
    - name: Find all .dpkg-* files
 | 
						|
      ansible.builtin.find:
 | 
						|
        paths: /etc
 | 
						|
        file_type: file
 | 
						|
        recurse: true
 | 
						|
        use_regex: false
 | 
						|
        patterns:
 | 
						|
          - "*.dpkg-*"
 | 
						|
      become: true
 | 
						|
      register: check__dpkg_files
 | 
						|
 | 
						|
    - name: Create variable for list of all .dpkg-* files
 | 
						|
      ansible.builtin.set_fact:
 | 
						|
        check__dpkg_files_list: [ ]
 | 
						|
 | 
						|
    - name: Populate list of all .dpkg-* files
 | 
						|
      ansible.builtin.set_fact:
 | 
						|
        check__dpkg_files_list: "{{ check__dpkg_files_list + [item.path] }}"
 | 
						|
      loop: "{{ check__dpkg_files.files }}"
 | 
						|
 | 
						|
    - name: Print .dpkg-* files list
 | 
						|
      ansible.builtin.debug:
 | 
						|
        var: check__dpkg_files_list
 | 
						|
 | 
						|
    - name: Get all held packages
 | 
						|
      ansible.builtin.command: apt-mark showhold
 | 
						|
      when: ansible_facts['pkg_mgr'] == "apt"
 | 
						|
      changed_when: false
 | 
						|
      register: check__apt_mark_showhold
 | 
						|
 | 
						|
    - name: Print all held packages
 | 
						|
      ansible.builtin.debug:
 | 
						|
        var: check__apt_mark_showhold.stdout_lines
 | 
						|
      when: check__apt_mark_showhold.stdout_lines != []
 |