# Upgrade via ansible



## cardoso_cristian (May 11, 2022)

Hi

I'm trying to perform the version upgrade from BSD 12.3-RELEASE to 13.0-RELEASE via ansible and I've created the following tasks:


```
- name: Applying major version upgrade
   command: freebsd-update --not-running-from-cron upgrade -r {{ version }}
   become: yes
   tags:
   - freebsd-upgrade

- name: Apply update installation
   command: freebsd-update --not-running-from-cron install
   become: yes
   tags:
   - freebsd-upgrade

- name: Reboot after upgrade
   shell: "sleep 5 && reboot"
   async: 1
   poll: 0
   become: yes
   tags:
   - freebsd-upgrade


- name: Waiting for machine reboot (max 600s)
   wait_for_connection:
     connect_timeout: 20
     sleep: 20
     delay: 60
     timeout: 600
   tags:
   - freebsd-upgrade

- name: Running freebsd install userland
   command: freebsd-update --not-running-from-cron install
   become: yes
   tags:
   - freebsd-upgrade
```

I know that the upgrade takes a while to apply to the system, but is there any kind of log that the upgrade generates to see if the upgrade is working correctly through the --not-running-from-cron command?


----------



## cardoso_cristian (May 11, 2022)

I believe sending the command via ansible
Everything is stopping at the question before starting the upgrade


```
The following components of FreeBSD do not seem to be installed:
world/base-dbg world/lib32-dbg

Does this look reasonable (y/n)?
```

This command doesn't support -y for execution, does anyone know any way to automate this?


----------



## monwarez (May 11, 2022)

The freebsd-update install process is not design to be done in an non interactive way: how will you manage conflict ? If you say use new version of file, you may be in the case where /etc/master.passwd conflict and then it will simply be reset to a default file.
You may try something like this:
`yes | freebsd-update install`
Not sure that this would work correctly.


----------



## SirDice (May 12, 2022)

Patch updates can be done with Ansible, those are relatively simple to implement. Major version upgrades however are best done by hand, as monwarez correctly stated, the process is often interactive.

In bigger environments major version upgrades are usually not done _inplace_. You kill the VM with the old version and spin up a new VM with the new major version. Then your Ansible/Puppet/Whatever will configure that machine for the task it needs. Data is separated from the OS so this needs to be reconnected to the new VM and you're good to go.


----------



## Alain De Vos (May 12, 2022)

Yep, upgrading the kernel and userland and etc is traditionally a manual thing in freebsd.
It's just tradition.
All the rest can be automated.
It's possible to automate interactive stuff with ansible , but only these things which don't change...


----------

