From 6eb4b64fb876e8a73af89ec63cf38dc936216035 Mon Sep 17 00:00:00 2001 From: Nicola Belluti Date: Sat, 4 Oct 2025 07:32:14 +0200 Subject: [PATCH] Added the base for the Ansible provisioning --- setup-script/.gitignore | 2 ++ setup-script/ansible.cfg | 27 +++++++++++++++++++++++++++ setup-script/playbook.yaml | 17 +++++++++++++++++ setup-script/requirements.txt | 1 + setup-script/roles/.gitkeep | 0 5 files changed, 47 insertions(+) create mode 100644 setup-script/.gitignore create mode 100644 setup-script/ansible.cfg create mode 100644 setup-script/playbook.yaml create mode 100644 setup-script/requirements.txt create mode 100644 setup-script/roles/.gitkeep diff --git a/setup-script/.gitignore b/setup-script/.gitignore new file mode 100644 index 0000000..fcc74c8 --- /dev/null +++ b/setup-script/.gitignore @@ -0,0 +1,2 @@ +.ansible +.venv diff --git a/setup-script/ansible.cfg b/setup-script/ansible.cfg new file mode 100644 index 0000000..a59f144 --- /dev/null +++ b/setup-script/ansible.cfg @@ -0,0 +1,27 @@ +[defaults] +# (path) The default root path for Ansible config files on the controller. +home=./.ansible + +# (boolean) If you have cowsay installed but want to avoid the 'cows' (why????), use this. +nocows = true + +# (pathspec) Colon separated paths in which Ansible will search for Roles. +roles_path = ./roles + +# (boolean) By default, Ansible will issue a warning when there are no hosts in the inventory. +# These warnings can be silenced by adjusting this setting to False. +localhost_warning = false + +# (str) Define the task result format used in the callback output. +# These formats do not cause the callback to emit valid JSON or YAML formats. +# The output contains these formats interspersed with other non-machine parsable data. +callback_result_format = yaml + +[diff] +# (bool) Configuration toggle to tell modules to show differences when in 'changed' status, equivalent to ``--diff``. +always = true + +[inventory] +# (boolean) By default, Ansible will issue a warning when no inventory was loaded and notes that it will use an implicit localhost-only inventory. +# These warnings can be silenced by adjusting this setting to False. +inventory_unparsed_warning = false diff --git a/setup-script/playbook.yaml b/setup-script/playbook.yaml new file mode 100644 index 0000000..85e3022 --- /dev/null +++ b/setup-script/playbook.yaml @@ -0,0 +1,17 @@ +- name: Prepare the base environment + hosts: localhost + connection: local + gather_facts: false + + pre_tasks: + - name: 'Ensure the "chezmoi" variable is set' + ansible.builtin.assert: + that: + - chezmoi is not undefined + - chezmoi is mapping + fail_msg: 'Pass with: --extra-vars "$(chezmoi data --format=json)"' + + - name: 'Example: access the "user" fields' + ansible.builtin.debug: + msg: + - "user: {{ chezmoi.username | default('n/a') }}" diff --git a/setup-script/requirements.txt b/setup-script/requirements.txt new file mode 100644 index 0000000..8a8ae04 --- /dev/null +++ b/setup-script/requirements.txt @@ -0,0 +1 @@ +ansible == 12.0.0 diff --git a/setup-script/roles/.gitkeep b/setup-script/roles/.gitkeep new file mode 100644 index 0000000..e69de29