document uv python package manager command for ansible setup - minor fixes in playbook

This commit is contained in:
2025-08-05 12:22:27 +02:00
parent 58aece92b6
commit b8636a6d48
5 changed files with 34 additions and 7 deletions

1
.python-version Normal file
View File

@@ -0,0 +1 @@
3.12

View File

@@ -38,7 +38,8 @@ ansible-playbook ansible/arcodange/factory/playbooks/03_cicd.yml -i ansible/arco
ANSIBLE_VAULT_PASSWORD_FILE=~/.local/bin/read-vault-key.sh;
mkdir -p `dirname $ANSIBLE_VAULT_PASSWORD_FILE`; set +o histexpand;
echo -e "#!/bin/bash\nkubectl get secret -n kube-system arcodange-ansible-vault --template='{{index .data.pass | base64decode}}'" > $ANSIBLE_VAULT_PASSWORD_FILE;
set -o histexpand; chmod +x $ANSIBLE_VAULT_PASSWORD_FILE; echo "export ANSIBLE_VAULT_PASSWORD_FILE=$ANSIBLE_VAULT_PASSWORD_FILE" >> `find ~ -maxdepth 1 -type f -name '\.*profile' -or -name '\.bashrc' | head -n1`
set -o histexpand; chmod +x $ANSIBLE_VAULT_PASSWORD_FILE; echo "export ANSIBLE_VAULT_PASSWORD_FILE=$ANSIBLE_VAULT_PASSWORD_FILE" >> `find ~ -maxdepth 1 -type f -name '\.*profile' -or -name '\.bashrc' -or -name '\.zshenv' | head -n1`
export ANSIBLE_VAULT_PASSWORD_FILE
```
### a tool to reuse a ssh agent (not required)
@@ -64,7 +65,33 @@ ssh-add ~/.ssh/id_rsa
ansible -i ,localhost -c local localhost -m raw -a "echo hello world {{ inventory_hostname }} : {{ hostvars | to_nice_json | regex_replace(\"['\n]\",' ') }}"
```
### local python environment with pipx
### local python environment with uv
#### add dependency
- `pipx runpip ansible-core install dnspython`
#### Install UV
`python3 -m pip install uv`
`python3 -m uv python install 3.10 3.11 3.12`
`echo "export PATH=\"$(find ~/Library/Python/*/bin/uv | xargs dirname)\"" >> ~/.zshenv`
`echo 'export PATH="~/.local/bin:$PATH"' >> ~/.zshenv`
#### Set python version to 3.12
`uv python pin 3.12` (edit .python-version file)
#### Install ansible
`uv tool install ansible-core --with dnspython`
`echo 'export PATH="~/.local/share/uv/tools/ansible-core/bin:$PATH"' >> ~/.zshenv`
#### Install this project depedencies
```
ansible-galaxy collection install --token 11bebd8fd1ad4009f700bdedbeb80b19743ce3d3 -r ansible/requirements.yml # token is used by a rate limiter and can be sensitive
```
#### Run
```
ansible-galaxy collection install ./ansible/arcodange/factory -f
```

View File

@@ -1,4 +1,4 @@
gitea_version: 1.23.3
gitea_version: 1.24.3
gitea_partition: |-
{{

View File

@@ -27,7 +27,6 @@ local:
hosts:
localhost:
ansible_connection: local
ansible_python_interpreter: /Users/gabrielradureau/.local/pipx/venvs/ansible-core/bin/python
pi1:
pi2:
pi3:

View File

@@ -54,6 +54,6 @@
'deleted' if gitea_token_delete else
(
(gitea_api_token_cmd.rc == 0)
| ternary(gitea_api_token_cmd.stdout, gitea_api_token_cmd_bis.stdout)
| ternary(gitea_api_token_cmd.stdout, gitea_api_token_cmd_bis.stdout | default(''))
)
}}