Reputation: 1317
I each of my remote servers I want to run the equivalent of:
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
Before running anything, when I login in the Server I get the following messages:
Welcome to Ubuntu 18.10 (GNU/Linux 4.18.0-10-generic x86_64)
...
...
132 packages can be updated.
79 updates are security updates.
Then, I run the following playbook:
---
- hosts: myserver
remote_user: root
become: yes
become_method: sudo
tasks:
- name: "Update packages"
apt:
update_cache: yes # apt-get update
upgrade: full
- name: "Update dist"
apt:
upgrade: dist
- name: UpdateRaw
shell: apt-get update -y
- name: UpgradeRaw
shell: apt-get upgrade -y
- name: DistUpgradeRaw
shell: sudo apt-get dist-upgrade -y
using the command
ansible-playbook -i hosts update.yml --check
But when I go back to server I still see the same message:
Welcome to Ubuntu 18.10 (GNU/Linux 4.18.0-10-generic x86_64)
...
...
132 packages can be updated.
79 updates are security updates.
How do I update my server using ansible?
Upvotes: 1
Views: 3010
Reputation: 1820
The --check option executes ansible in dry run mode. You need to remove the --check flag, in order to actually execute the play on the remote hosts. The correct command is:
ansible-playbook -i hosts update.yml
Please see below link
Upvotes: 1