Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 May 2022 12:57:03 -0300
From:      Cristian Cardoso <cristian.cardoso11@gmail.com>
To:        Alan Somers <asomers@freebsd.org>
Cc:        FreeBSD CURRENT <freebsd-current@freebsd.org>
Subject:   Re: Upgrade automation
Message-ID:  <CAKeEC-LoenkK4NPxpCsTN%2Bk%2BCqksNHh6JfJM1YmE4YASkpZtgg@mail.gmail.com>
In-Reply-To: <CAOtMX2hObotfGtjSoW6HftzP9bZ05d2OPFK2krKW9_6a0r97mQ@mail.gmail.com>
References:  <CAKeEC-%2Bwqzz_qrHWhCsTGcM9%2B%2BGdMouX8TEGWhCJ2Y%2B5=-nfUA@mail.gmail.com> <CAOtMX2hObotfGtjSoW6HftzP9bZ05d2OPFK2krKW9_6a0r97mQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000d6d2f705deaa60ae
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I currently update patches this way:


- name: Checking for updates on FreeBSD
   command: freebsd-update fetch
   when:
     - ansible_distribution =3D=3D "FreeBSD"
   register: result_update
   changed_when: "'No updates needed' not in result_update.stdout"
   become: yes
   tags:
   - check-update

- name: Applying update on FreeBSD
   command: freebsd-update install
   when:
     - ansible_distribution =3D=3D "FreeBSD" and result_update.changed
   register: result_update_install
   become: yes
   tags:
   - apply-update



Maybe to get around the situation after the version upgrade task, you can
do something like this:


- name: Reboot system to apply new kernel
   shell: "sleep 5 && reboot"
   async: 1
   poll: 0
   become: True

- name: Wait for reconnection to system to continue update
   wait_for_connection:
     connect_timeout: 20
     sleep: 20
     delay: 60
     timeout: 600

- name: Applying update on FreeBSD
   command: freebsd-update install
   when:
     - ansible_distribution =3D=3D "FreeBSD" and result_update.changed
   register: result_update_install
   become: yes



Em ter., 10 de mai. de 2022 =C3=A0s 12:47, Alan Somers <asomers@freebsd.org=
>
escreveu:

> On Tue, May 10, 2022 at 9:08 AM Cristian Cardoso
> <cristian.cardoso11@gmail.com> wrote:
> >
> > Hi
> >
> > I have some FreeBSD servers in my machine park and I would like to
> perform the version upgrade in an automated way with ansible.
> >
> > In my example, I want to perform the upgrade from version 12.3 to 13, i=
t
> is possible to run the upgrade with the command below:
> >
> > freebsd-update --not-running-from-cron upgrade -r 12.2-RELEASE
> >
> > I ask this, because I don't know if it's the most correct way to execut=
e
> this.
> >
> > Grateful for any assistance.
>
> Yes, that's perfect.  But there's another step too.  You'll have to do:
> freebsd-update install
> And _this_ step isn't easy to perfectly automate, because etcupdate
> may ask for your input when it merges config files.  If you know
> exactly which etc files you've modified, you can add them to
> IgnorePaths.  That way etcupdate won't run interactively, it will
> simply throw away changes from upstream.
>
> Whenever I need to upgrade multiple machines at once, I start tmux,
> split it into multiple panes, ssh to each server from one pane, then
> do ":synchronize-panes on" so my input will be directed to multiple
> panes simultaneously.  Usually, that works for 90% of the upgrade.
> But invariably there are a few files that aren't synchronized between
> the servers, and I have to desynchronize my panes to deal with that.
>
> -Alan
>

--000000000000d6d2f705deaa60ae
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I currently update patches this way:<div><br><br>- name: C=
hecking for updates on FreeBSD<br>=C2=A0 =C2=A0command: freebsd-update fetc=
h<br>=C2=A0 =C2=A0when:<br>=C2=A0 =C2=A0 =C2=A0- ansible_distribution =3D=
=3D &quot;FreeBSD&quot;<br>=C2=A0 =C2=A0register: result_update<br>=C2=A0 =
=C2=A0changed_when: &quot;&#39;No updates needed&#39; not in result_update.=
stdout&quot;<br>=C2=A0 =C2=A0become: yes<br>=C2=A0 =C2=A0tags:<br>=C2=A0 =
=C2=A0- check-update<br><br>- name: Applying update on FreeBSD<br>=C2=A0 =
=C2=A0command: freebsd-update install<br>=C2=A0 =C2=A0when:<br>=C2=A0 =C2=
=A0 =C2=A0- ansible_distribution =3D=3D &quot;FreeBSD&quot; and result_upda=
te.changed<br>=C2=A0 =C2=A0register: result_update_install<br>=C2=A0 =C2=A0=
become: yes<br>=C2=A0 =C2=A0tags:<br>=C2=A0 =C2=A0- apply-update<br><div><b=
r></div><div><br></div><div><br></div><div>Maybe to get around the situatio=
n after the version upgrade task, you can do something like this:<br><br><b=
r>- name: Reboot system to apply new kernel<br>=C2=A0 =C2=A0shell: &quot;sl=
eep 5 &amp;&amp; reboot&quot;<br>=C2=A0 =C2=A0async: 1<br>=C2=A0 =C2=A0poll=
: 0<br>=C2=A0 =C2=A0become: True<br><br>- name: Wait for reconnection to sy=
stem to continue update<br>=C2=A0 =C2=A0wait_for_connection:<br>=C2=A0 =C2=
=A0 =C2=A0connect_timeout: 20<br>=C2=A0 =C2=A0 =C2=A0sleep: 20<br>=C2=A0 =
=C2=A0 =C2=A0delay: 60<br>=C2=A0 =C2=A0 =C2=A0timeout: 600<br><br>- name: A=
pplying update on FreeBSD<br>=C2=A0 =C2=A0command: freebsd-update install<b=
r>=C2=A0 =C2=A0when:<br>=C2=A0 =C2=A0 =C2=A0- ansible_distribution =3D=3D &=
quot;FreeBSD&quot; and result_update.changed<br>=C2=A0 =C2=A0register: resu=
lt_update_install<br>=C2=A0 =C2=A0become: yes<br></div><div><br></div><div>=
<br></div></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=
=3D"gmail_attr">Em ter., 10 de mai. de 2022 =C3=A0s 12:47, Alan Somers &lt;=
<a href=3D"mailto:asomers@freebsd.org">asomers@freebsd.org</a>&gt; escreveu=
:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.=
8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Tue, May 10=
, 2022 at 9:08 AM Cristian Cardoso<br>
&lt;<a href=3D"mailto:cristian.cardoso11@gmail.com" target=3D"_blank">crist=
ian.cardoso11@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Hi<br>
&gt;<br>
&gt; I have some FreeBSD servers in my machine park and I would like to per=
form the version upgrade in an automated way with ansible.<br>
&gt;<br>
&gt; In my example, I want to perform the upgrade from version 12.3 to 13, =
it is possible to run the upgrade with the command below:<br>
&gt;<br>
&gt; freebsd-update --not-running-from-cron upgrade -r 12.2-RELEASE<br>
&gt;<br>
&gt; I ask this, because I don&#39;t know if it&#39;s the most correct way =
to execute this.<br>
&gt;<br>
&gt; Grateful for any assistance.<br>
<br>
Yes, that&#39;s perfect.=C2=A0 But there&#39;s another step too.=C2=A0 You&=
#39;ll have to do:<br>
freebsd-update install<br>
And _this_ step isn&#39;t easy to perfectly automate, because etcupdate<br>
may ask for your input when it merges config files.=C2=A0 If you know<br>
exactly which etc files you&#39;ve modified, you can add them to<br>
IgnorePaths.=C2=A0 That way etcupdate won&#39;t run interactively, it will<=
br>
simply throw away changes from upstream.<br>
<br>
Whenever I need to upgrade multiple machines at once, I start tmux,<br>
split it into multiple panes, ssh to each server from one pane, then<br>
do &quot;:synchronize-panes on&quot; so my input will be directed to multip=
le<br>
panes simultaneously.=C2=A0 Usually, that works for 90% of the upgrade.<br>
But invariably there are a few files that aren&#39;t synchronized between<b=
r>
the servers, and I have to desynchronize my panes to deal with that.<br>
<br>
-Alan<br>
</blockquote></div>

--000000000000d6d2f705deaa60ae--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAKeEC-LoenkK4NPxpCsTN%2Bk%2BCqksNHh6JfJM1YmE4YASkpZtgg>