refactor: update package management tasks in linux_updates.yaml and install_openitcockpit.yaml

This commit is contained in:
2025-09-10 08:03:43 -04:00
parent ee5fe4f78f
commit 68fb357795
2 changed files with 47 additions and 46 deletions
+33 -23
View File
@@ -1,35 +1,45 @@
---
- hosts: cockpithosts
- hosts: debianhosts
gather_facts: no
tasks:
# Copy remote file (host.example.com:/tmp/somefile) into
# /tmp/fetched/host.example.com/tmp/somefile on local machine
- ansible.builtin.copy:
src: ./files/openitcockpit-agent_3.1.1_amd64.deb
dest: /tmp/openitcockpit-agent_3.1.1_amd64.deb
owner: root
group: root
mode: '0644'
# - ansible.builtin.copy:
# src: ./files/openitcockpit-agent_3.1.1_amd64.deb
# dest: /tmp/openitcockpit-agent_3.1.1_amd64.deb
# owner: root
# group: root
# mode: '0644'
- name: change working directory
ansible.builtin.shell:
cmd: ls -l
chdir: /tmp
# - name: change working directory
# ansible.builtin.shell:
# cmd: ls -l
# chdir: /tmp
- name: Install openitcockpit agent
ansible.builtin.shell:
cmd: dpkg -i /tmp/openitcockpit-agent_3.1.1_amd64.deb
# - name: Install openitcockpit agent
# ansible.builtin.shell:
# cmd: dpkg -i /tmp/openitcockpit-agent_3.1.1_amd64.deb
- ansible.builtin.copy:
src: ./files/config.ini
dest: /etc/openitcockpit-agent/config.ini
owner: root
group: root
mode: '0644'
# - ansible.builtin.copy:
# src: ./files/config.ini
# dest: /etc/openitcockpit-agent/config.ini
# owner: root
# group: root
# mode: '0644'
- name: Restart openitcockpit agent
ansible.builtin.shell:
cmd: systemctl restart openitcockpit-agent
# - name: Restart openitcockpit agent
# ansible.builtin.shell:
# cmd: systemctl restart openitcockpit-agent
- name: Remove a package
hosts: all
become: yes # Run tasks with sudo privileges
tasks:
- name: Remove the 'opencockpit' package
ansible.builtin.apt:
name: openitcockpit-agent
state: absent
# - name: Install a list of packages
# ansible.builtin.apt:
+14 -23
View File
@@ -23,31 +23,22 @@
- hosts: debianhosts
gather_facts: no
tasks:
# - name: Update all installed packages using APT module
# apt:
# name: '*'
# state: latest
# update_cache: yes
# only_upgrade: yes
# register: apt_update_status
- name: Update all installed packages using APT module
apt:
name: '*'
state: latest
update_cache: yes
only_upgrade: yes
register: apt_update_status
# - name: Remove packages not needed anymore
# apt:
# autoremove: yes
- name: Remove packages not needed anymore
apt:
autoremove: yes
# - name: Reboot when packages were updated
# reboot:
# post_reboot_delay: 60
# when: apt_update_status.changed
- name: Remove a package
hosts: all
become: yes # Run tasks with sudo privileges
tasks:
- name: Remove the 'opencockpit' package
ansible.builtin.apt:
name: openitcockpit-agent
state: absent
- name: Reboot when packages were updated
reboot:
post_reboot_delay: 60
when: apt_update_status.changed
#- hosts: apkhosts
# tasks: