# pkg upgrade itself automatically



## tommiie (Oct 22, 2020)

I want to configure my FreeBSD virtual machine with Ansible but run into the following issue:

```
>vagrant provision
==> white: Running provisioner: ansible_local...
    white: Installing Ansible...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

pkg install -qy py36-ansible

Stdout from the command:

New version of pkg detected; it needs to be installed first.


Stderr from the command:

pkg: Repository FreeBSD has a wrong packagesite, need to re-create database
pkg: Failed to execute lua script: [string "args = {}..."]:11: attempt to call a nil value (field 'stat')
pkg: No packages available to install matching 'py36-ansible' have been found in the repositories
```

However, having Vagrant first run a command to upgrade pkg(1) is also not possible:


```
root@testserver:/home/vagrant # pkg upgrade -qy pkg
New version of pkg detected; it needs to be installed first.
pkg: Failed to execute lua script: [string "args = {}..."]:11: attempt to call a nil value (field 'stat')
```

I don't want to do a `pkg upgrade` as that would mean I have no absolute control anymore over which version of packages I have installed. This is not a disaster but I thought the general consensus is that you want absolute control over your software versions in Infrastructure as a Service.

Any ideas on how to solve this? Or should I just use `pkg upgrade -qy` and don't care about the specific software versions?


----------



## tingo (Oct 24, 2020)

As part of my bootstrap of ansible on a FreeBSD host I do this:

```
ASSUME_ALWAYS_YES=yes pkg bootstrap
pkg update
pkg install -y python37 sudo
```
this is all done with the 'raw' module of ansible. after that "normal" ansible works, like setting up passwordless sudo for the wheel group and so on.
Note: I'm fairly new to using ansible for FreeBSD hosts; this might not be the best way. YMMV.


----------

