# ansible-navigator

## build new execution environment

1. set up venv

```
python -m venv kvant-venv
source kvant-venv/bin/activate
kvant-venv/bin/python -m pip install --upgrade pip
pip install -r requirements.txt
```

2. build execution environment

```
cd ansible-ee
TMPDIR=/srv/builder/ansible-builder ansible-builder build -t kvant-ee --no-cache
```

3. Configure ansible-navigator

Create a config file to configure `ansible-navigator`, primarily the EE image.

```
$ cat $HOME/.ansible-navigator.yaml
ansible-navigator:
  execution-environment:
    container-engine: podman
    image: docker.nexus-rkvn.cicd.phoenix-systems.ch/kvant-ee:latest
    pull:
      policy: never
```

Note: An overview of all available options can be found under https://ansible.readthedocs.io/projects/navigator/settings/#execution-environment-image.

4. run playbooks with custom execution environment

```
ansible-navigator run <your-playbook.yml>
```

## run playbooks with execution environment

1. set up venv

```
python -m venv kvant-venv
source kvant-venv/bin/activate
kvant-venv/bin/python -m pip install --upgrade pip
pip install -r requirements.txt
```

2. run playbooks with custom execution environment

```
ansible-navigator run <your-playbook.yml>
```

## add dependencies

1. set up venv

```
python -m venv kvant-venv
source kvant-venv/bin/activate
kvant-venv/bin/python -m pip install --upgrade pip
pip install -r requirements.txt
```

2. pip packages

run `pip install x` to add packages in the vnenv.
then run `pip freeze > requirements.txt` to capture current state.

3. ansible modules

add to `collection-requirements.yml` file/

4. binaries

add to `ansible-ee/bindep.txt`

5. build execution environment

```
cd ansible-ee
TMPDIR=/srv/builder/ansible-builder ansible-builder build -t kvant-ee --no-cache
```

if the `context` dir already exists locally from previous builds, it is possible to alternatively use podman directly e.g.

```
TMPDIR=/srv/builder/ansible-builder podman build -f context/Containerfile -t kvant-ee context
```
