From 863623e3b0ee4d6c5acab4fd47217a68be269791 Mon Sep 17 00:00:00 2001 From: Salt Date: Tue, 28 Jul 2020 06:44:33 -0500 Subject: [PATCH] Factor extended hostnames into existing roles Ow, really feeling that maintainability hit --- roles/desktop/templates/backup.sh | 6 +++--- roles/dns/tasks/main.yml | 2 +- roles/minecraft/tasks/main.yml | 4 ++-- roles/nagios/tasks/main.yml | 2 +- roles/sourcegame/tasks/main.yml | 2 +- roles/user/tasks/main.yml | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/roles/desktop/templates/backup.sh b/roles/desktop/templates/backup.sh index 5c9690b..51b91dc 100644 --- a/roles/desktop/templates/backup.sh +++ b/roles/desktop/templates/backup.sh @@ -9,7 +9,7 @@ set -e -export OUTDIR="$BACKUPSDIR/{{ inventory_hostname }}" +export OUTDIR="$BACKUPSDIR/{{ inventory_hostname_short }}" retention=7 # 7-day retention period # Sanity checks @@ -40,7 +40,7 @@ for dir in /home/*; do forcefile="$dir/.backup/force" [ -d "$dir/.backup" ] || continue for file in "$dir/.backup/"*; do [ -e "$file" ] || continue; done - tar czhf "$OUTDIR/desktop-$username-{{ inventory_hostname }}-$(date -Iseconds).tar.gz" "$dir/.backup/"* + tar czhf "$OUTDIR/desktop-$username-{{ inventory_hostname_short }}-$(date -Iseconds).tar.gz" "$dir/.backup/"* # if (( "$(date +%d)" == "1" )) || [ -f "$forcefile" ]; then # log "Detected conditions for monthly dump" # if command -v aws > /dev/null 2>&1 && aws s3 ls "s3://$s3bucket" > /dev/null 2>&1; then @@ -55,7 +55,7 @@ for dir in /home/*; do # --exclude "$dir/Nextcloud" \ # --exclude "$dir/snap" \ # "$dir/."* \ -# | aws s3 cp - "s3://$s3bucket/{{ inventory_hostname }}/desktop-$username-{{ inventory_hostname }}-$(date -Iseconds)-full.tar.gz" \ +# | aws s3 cp - "s3://$s3bucket/{{ inventory_hostname_short }}/desktop-$username-{{ inventory_hostname_short }}-$(date -Iseconds)-full.tar.gz" \ # --only-show-errors \ # --storage-class STANDARD_IA # else diff --git a/roles/dns/tasks/main.yml b/roles/dns/tasks/main.yml index 1bf3e9b..7011d36 100644 --- a/roles/dns/tasks/main.yml +++ b/roles/dns/tasks/main.yml @@ -11,7 +11,7 @@ overwrite: yes zone: "{{ zone }}" type: A - record: "{{ inventory_hostname }}.{{ zone }}." + record: "{{ inventory_hostname_short }}.{{ zone }}." ttl: 300 value: - "{{ ipify_public_ip }}" diff --git a/roles/minecraft/tasks/main.yml b/roles/minecraft/tasks/main.yml index 49ea700..062e7f9 100644 --- a/roles/minecraft/tasks/main.yml +++ b/roles/minecraft/tasks/main.yml @@ -187,7 +187,7 @@ record: "{{ mcname }}.mc.{{ zone }}." ttl: 300 value: - - "{{ inventory_hostname }}.{{ zone }}." + - "{{ inventory_hostname_short }}.{{ zone }}." - name: Assure SRV record route53: state: present @@ -197,5 +197,5 @@ record: "_minecraft._tcp.{{ mcname }}.mc.{{ zone }}." ttl: 300 value: - - "1 10 {{ mcport }} {{ inventory_hostname }}.{{ zone }}." + - "1 10 {{ mcport }} {{ inventory_hostname_short }}.{{ zone }}." become: yes diff --git a/roles/nagios/tasks/main.yml b/roles/nagios/tasks/main.yml index 03ab670..7d9039d 100644 --- a/roles/nagios/tasks/main.yml +++ b/roles/nagios/tasks/main.yml @@ -18,7 +18,7 @@ record: "{{ nagios_url }}" ttl: 3600 value: - - "{{ inventory_hostname }}.{{ zone }}." + - "{{ inventory_hostname_short }}.{{ zone }}." - name: Set up Apache block: - name: Enable modules diff --git a/roles/sourcegame/tasks/main.yml b/roles/sourcegame/tasks/main.yml index 8e6d3b0..f71a792 100644 --- a/roles/sourcegame/tasks/main.yml +++ b/roles/sourcegame/tasks/main.yml @@ -45,5 +45,5 @@ record: "{{ source_instancename }}.src.{{ zone }}." ttl: 300 value: - - "{{ inventory_hostname }}.{{ zone }}." + - "{{ inventory_hostname_short }}.{{ zone }}." become: yes diff --git a/roles/user/tasks/main.yml b/roles/user/tasks/main.yml index f94dc65..4c5cf31 100644 --- a/roles/user/tasks/main.yml +++ b/roles/user/tasks/main.yml @@ -18,7 +18,7 @@ mode: "0700" - name: Generate keypair openssh_keypair: - comment: "{{ user_username }}@{{ inventory_hostname }}" + comment: "{{ user_username }}@{{ inventory_hostname_short }}" path: $HOME/.ssh/id_ed25519 mode: "0600" register: keypair @@ -33,7 +33,7 @@ body: key: "{{ keypair.public_key }}" read_only: yes - title: "{{ inventory_hostname }}-ed25519" + title: "{{ inventory_hostname_short }}-ed25519" status_code: 201 when: keypair is changed - name: Configure authorized hosts