Skip to content

Commit

Permalink
providers: fix badly named godaddy variable
Browse files Browse the repository at this point in the history
  • Loading branch information
saltydk committed Oct 17, 2023
1 parent e1f1d27 commit 568bc60
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion defaults/providers.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cloudns:
password:
duckdns:
token:
goddady:
godaddy:
api_key:
api_secret:
hetzner:
Expand Down
6 changes: 6 additions & 0 deletions roles/settings/tasks/subtasks/migrator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
- name: Migrator | 'backup_config.yml' | Migration 01
ansible.builtin.include_tasks: "migrator/backup_config_yml/migration_01.yml"

- name: Migrator | Migrations for 'providers.yml'
when: (file == "providers.yml")
block:
- name: Migrator | 'providers.yml' | Migration 01
ansible.builtin.include_tasks: "migrator/providers_yml/migration_01.yml"

- name: Migrator | Migrations for 'settings.yml'
when: (file == "settings.yml")
block:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
########################################################################################
# GNU General Public License v3.0 #
########################################################################################

---
- name: "Migrator | 'backup_config.yml' | Migration 01 | Set variables"
ansible.builtin.set_fact:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
########################################################################################
# Title: Saltbox: Settings | Migrator | 'providers.yml' | Migration 01 #
# Author(s): salty #
# URL: https://github.com/saltyorg/Saltbox #
# -- #
########################################################################################
# GNU General Public License v3.0 #
########################################################################################
---
- name: "Migrator | 'backup_config.yml' | Migration 01 | Set variables"
ansible.builtin.set_fact:
old_godaddy: "{{ (goddady is defined) }}"
old_godaddy_filled: "{{ (goddady is defined) and
(goddady is not none) and
(goddady | trim | length > 0) and
(goddady.api_key is defined) and
(goddady.api_key is not none) and
(goddady.api_key | length > 0) and
(goddady.api_secret is defined) and
(goddady.api_secret is not none) and
(goddady.api_secret | length > 0) }}"

- name: Migrator | 'backup_config.yml' | Migration 01 | Delete 'goddady' dict
ansible.builtin.shell: |
yyq e -i 'del(.goddady)' {{ playbook_dir }}/{{ file }}
become: true
become_user: "{{ saltbox_yml.stat.pw_name }}"
when: old_godaddy

- name: Migrator | 'backup_config.yml' | Migration 01 | Rebuild 'godaddy' dict
ansible.builtin.shell: |
yyq e -i '.godaddy.api_key = "{{ goddady.api_key }}"' {{ playbook_dir }}/{{ file }}
yyq e -i '.godaddy.api_secret = "{{ goddady.api_secret }}"' {{ playbook_dir }}/{{ file }}
become: true
become_user: "{{ saltbox_yml.stat.pw_name }}"
when: old_godaddy_filled

- name: Migrator | 'backup_config.yml' | Migration 01 | Remove 'null' values
ansible.builtin.replace:
path: "{{ playbook_dir }}/{{ file }}"
regexp: '(?<=: )\bnull\s*$'
replace: ''
owner: "{{ saltbox_yml.stat.uid }}"
group: "{{ saltbox_yml.stat.gid }}"
mode: "0664"

- name: Migrator | 'backup_config.yml' | Migration 01 | Re-import Variables
ansible.builtin.include_vars: "{{ playbook_dir }}/{{ file }}"

0 comments on commit 568bc60

Please sign in to comment.