From 09fd2d74d4a63148a11e186503eafb76a022e8ea Mon Sep 17 00:00:00 2001 From: SebClem Date: Fri, 30 Dec 2022 13:59:13 +0100 Subject: [PATCH] :hammer: Change folder structure --- .vscode/settings.json | 9 ++--- .woodpecker/ansible.yml | 36 +++++++++++++++++++ ansible.cfg | 3 +- .../group_vars}/nodes.yml | 0 .../host_vars}/hostname.yml | 0 hosts => inventories/hosts.yml | 1 - {secrets => inventories/secrets}/hostname.yml | 0 sites.yml => playbooks/install.yml | 4 +-- renovate.json | 2 +- 9 files changed, 46 insertions(+), 9 deletions(-) create mode 100644 .woodpecker/ansible.yml rename {group_vars => inventories/group_vars}/nodes.yml (100%) rename {host_vars => inventories/host_vars}/hostname.yml (100%) rename hosts => inventories/hosts.yml (98%) rename {secrets => inventories/secrets}/hostname.yml (100%) rename sites.yml => playbooks/install.yml (53%) diff --git a/.vscode/settings.json b/.vscode/settings.json index 95a5416..a5f45dc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,9 +1,10 @@ { "files.autoSave": "afterDelay", "files.associations": { - "hosts": "yaml", - "*.yml": "ansible" + "**hosts*": "yaml", + "*.yml": "ansible", + "**/.woodpecker/*.yml": "yaml" }, -"ansible.ansible.useFullyQualifiedCollectionNames": true, -"editor.formatOnSave": true + "ansible.ansible.useFullyQualifiedCollectionNames": true, + "editor.formatOnSave": true } diff --git a/.woodpecker/ansible.yml b/.woodpecker/ansible.yml new file mode 100644 index 0000000..48b0760 --- /dev/null +++ b/.woodpecker/ansible.yml @@ -0,0 +1,36 @@ +pipeline: + check-ansible-syntax: + image: harbor.sebclem.fr/sebclem/woodpecker-ansible-runner + pull: true + settings: + playbook: playbooks/install.yml + galaxy_file: roles/requirements.yml + check_syntax: true + vault_token: + from_secret: ansible_vault_token + when: + - event: "push" + branch: [main, master] + - event: [pull_request, manual, deployment] + + run-ansible-playbook: + image: harbor.sebclem.fr/sebclem/woodpecker-ansible-runner + pull: true + settings: + verbosity: ${verbosity=0} + limit: ${limit} + tags: ${tags} + playbook: playbooks/install.yml + galaxy_file: roles/requirements.yml + vault_token: + from_secret: ansible_vault_token + private_key: + from_secret: ansible_private_key + when: + environment: production + event: deployment + +when: + - event: "push" + branch: [main, master] + - event: [pull_request, manual, deployment] diff --git a/ansible.cfg b/ansible.cfg index f2a27eb..9043faa 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -1,8 +1,9 @@ [defaults] -inventory = hosts +inventory = inventories/hosts.yml remote_user = root host_key_checking = True vault_password_file = credentials/vault_token roles_path = ./roles force_color = true +stdout_callback = yaml ansible_managed = This file is managed by ansible, don't make changes here - they will be overwritten. diff --git a/group_vars/nodes.yml b/inventories/group_vars/nodes.yml similarity index 100% rename from group_vars/nodes.yml rename to inventories/group_vars/nodes.yml diff --git a/host_vars/hostname.yml b/inventories/host_vars/hostname.yml similarity index 100% rename from host_vars/hostname.yml rename to inventories/host_vars/hostname.yml diff --git a/hosts b/inventories/hosts.yml similarity index 98% rename from hosts rename to inventories/hosts.yml index 6bcc132..f31bbf5 100644 --- a/hosts +++ b/inventories/hosts.yml @@ -1,5 +1,4 @@ --- - all: children: nodes: diff --git a/secrets/hostname.yml b/inventories/secrets/hostname.yml similarity index 100% rename from secrets/hostname.yml rename to inventories/secrets/hostname.yml diff --git a/sites.yml b/playbooks/install.yml similarity index 53% rename from sites.yml rename to playbooks/install.yml index 2f8dd9d..6e1070d 100644 --- a/sites.yml +++ b/playbooks/install.yml @@ -4,8 +4,8 @@ pre_tasks: - name: Load secrets - include_vars: - file: "secrets/{{ inventory_hostname }}.yml" + ansible.builtin.include_vars: + file: "{{ inventory_dir }}/secrets/{{ inventory_hostname }}.yml" tags: - always diff --git a/renovate.json b/renovate.json index 0256893..856128a 100644 --- a/renovate.json +++ b/renovate.json @@ -3,7 +3,7 @@ "extends": [ "config:base", "group:nodeJs", - "local>sebclem/renovate-configs:notest", + "local>sebclem/renovate-configs", "local>sebclem/renovate-configs:ansible_host_var" ] }