need playbook to update ubuntu and centos

57 views
Skip to first unread message

Tony Wong

unread,
Sep 24, 2020, 1:39:16 PM9/24/20
to ansible...@googlegroups.com
how can i update both ubuntu and centos boxes all in one playbook?

Dick Visser

unread,
Sep 24, 2020, 1:55:43 PM9/24/20
to ansible...@googlegroups.com
How do you perform that currently?

On Thu, 24 Sep 2020 at 19:39, Tony Wong <tdub...@gmail.com> wrote:
how can i update both ubuntu and centos boxes all in one playbook?









--


You received this message because you are subscribed to the Google Groups "Ansible Project" group.


To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CALmkhkoQAzbAgo1bzhv3eCe3rhS7Wy2APg44EDT04yt%2B%3DWFj%2BA%40mail.gmail.com.


--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Idan Melamed

unread,
Sep 24, 2020, 1:57:38 PM9/24/20
to Ansible Project
I suggest taking a look at the service module
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/service_module.html
You can use this module to update both YUM and APT packages.

Some packages have different names, so be sure to take that into account.
You can see an example here:
https://youtu.be/CYghlf-6Opc?t=929

ebcak random

unread,
Sep 26, 2020, 5:09:25 PM9/26/20
to Ansible Project
You can simply plagiarize the Ansible docs for yum to upgrade

and apt  to upgrade

however this is all dependent on your requirements, I use a precheck, upgrade, changelog collection of playbooks with host logic for the Linux hosts I currently maintain, depends on your estate.

Tony Wong

unread,
Sep 28, 2020, 1:02:09 PM9/28/20
to Ansible Project

this is all i have for ubuntu system. please advise



---
- hosts: ubuntu
  become: true
  become_user: root
  tasks:
    - name: Update apt repo/cache
      apt: update_cache=yes
      force_apt_get=yes
      cache_valid_time=3600

    - name: Upgrade all packages on servers
      apt: upgrade=dist
      force_apt_get=yes

    - name: Check if a reboot is needed on all servers
      register: reboot_required_file
      stat: path=/var/run/reboot-required get_md5=no

    - name: Reboot the box if kernel updated
      reboot:
        msg: "Reboot initiated by Ansible for kernel updates"
        connect_timeout: 5
        reboot_timeout: 300
        pre_reboot_delay: 0
        post_reboot_delay: 30
        test_command: uptime
      when: reboot_required_file.stat.exists

Dick Visser

unread,
Sep 28, 2020, 1:28:23 PM9/28/20
to ansible...@googlegroups.com
On Mon, 28 Sep 2020 at 19:02, Tony Wong <tdub...@gmail.com> wrote:
>
>
> this is all i have for ubuntu system. please advise

What advice are you looking for?
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/3558608e-741f-4a75-96c9-e014b57bba1fn%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Tony Wong

unread,
Sep 28, 2020, 1:29:15 PM9/28/20
to Ansible Project
advice. Need to add the yum part for centos

need some examples

Tony Wong

unread,
Sep 28, 2020, 1:57:29 PM9/28/20
to ansible...@googlegroups.com
also i want to know how to break this into a role instead

You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/vi_MG4aR2uA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/3d5b1e16-1cbd-46ad-8086-a983d6d29e99n%40googlegroups.com.

Dick Visser

unread,
Sep 28, 2020, 3:09:56 PM9/28/20
to ansible...@googlegroups.com
On Mon, 28 Sep 2020 at 19:29, Tony Wong <tdub...@gmail.com> wrote:
>
> advice. Need to add the yum part for centos
>
> need some examples

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/yum_module.html#examples

Dick Visser

unread,
Sep 28, 2020, 3:11:31 PM9/28/20
to ansible...@googlegroups.com
On Mon, 28 Sep 2020 at 19:56, Tony Wong <tdub...@gmail.com> wrote:
>
> also i want to know how to break this into a role instead

https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html
Reply all
Reply to author
Forward
0 new messages