From fb0c1f09011721972a68504b0f5049bc787e77e2 Mon Sep 17 00:00:00 2001 From: Felix Stupp Date: Tue, 19 Nov 2019 13:10:36 +0100 Subject: [PATCH] Changed "ansible_fqdn" to "inventory_hostname" Due to some hosts misconfigure fqdn themselves --- roles/account/tasks/main.yml | 2 +- roles/common/tasks/main.yml | 4 ++-- roles/common/tasks/sshd.yml | 6 +++--- roles/mysql/application/tasks/main.yml | 2 +- roles/nginx/application/tasks/main.yml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/roles/account/tasks/main.yml b/roles/account/tasks/main.yml index b0abd3a..c11a228 100644 --- a/roles/account/tasks/main.yml +++ b/roles/account/tasks/main.yml @@ -27,7 +27,7 @@ ssh_key_type: ed25519 ssh_key_file: .ssh/id_ed25519 ssh_key_passphrase: "{{ password }}" - ssh_key_comment: "{{ username }}@{{ ansible_fqdn }} {{ ansible_date_time.date }}" + ssh_key_comment: "{{ username }}@{{ inventory_hostname }} {{ ansible_date_time.date }}" - name: Configure home directory file: diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 5754124..0342db5 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -24,13 +24,13 @@ state: present generate_ssh_key: yes ssh_key_type: ed25519 - ssh_key_comment: "root@{{ ansible_fqdn }}" + ssh_key_comment: "root@{{ inventory_hostname }}" register: root_user - name: Store ssh public key local copy: content: "{{ root_user.ssh_public_key }}\n" - dest: "public_keys/ssh/root@{{ ansible_fqdn }}" + dest: "public_keys/ssh/root@{{ inventory_hostname }}" delegate_to: localhost vars: ansible_become: no diff --git a/roles/common/tasks/sshd.yml b/roles/common/tasks/sshd.yml index f99aec5..90d6bd8 100644 --- a/roles/common/tasks/sshd.yml +++ b/roles/common/tasks/sshd.yml @@ -46,7 +46,7 @@ - name: Create directory for host keys locally file: - path: "{{ global_ssh_host_key_directory }}/{{ ansible_fqdn }}" + path: "{{ global_ssh_host_key_directory }}/{{ inventory_hostname }}" state: directory owner: "{{ global_local_user }}" group: "{{ global_local_user }}" @@ -56,7 +56,7 @@ - name: Store ssh host keys locally copy: content: "{{ item.stdout }}\n" - dest: "{{ global_ssh_host_key_directory }}/{{ ansible_fqdn }}/{{ item.item }}" + dest: "{{ global_ssh_host_key_directory }}/{{ inventory_hostname }}/{{ item.item }}" owner: "{{ global_local_user }}" group: "{{ global_local_user }}" mode: "u=rw,g=r,o=r" @@ -67,7 +67,7 @@ - name: Generate ssh host key dns fingerprints locally make: - chdir: "{{ global_ssh_host_key_directory }}/{{ ansible_fqdn }}" + chdir: "{{ global_ssh_host_key_directory }}/{{ inventory_hostname }}" file: "{{ playbook_dir }}/helpers/ssh_dns_fingerprints.makefile" target: dns delegate_to: localhost diff --git a/roles/mysql/application/tasks/main.yml b/roles/mysql/application/tasks/main.yml index bd505f7..80ee249 100644 --- a/roles/mysql/application/tasks/main.yml +++ b/roles/mysql/application/tasks/main.yml @@ -47,7 +47,7 @@ - name: Disable public root user access mysql_user: user: "root" - host: "{{ ansible_fqdn }}" + host: "{{ inventory_hostname }}" state: absent login_unix_socket: /var/run/mysqld/mysqld.sock diff --git a/roles/nginx/application/tasks/main.yml b/roles/nginx/application/tasks/main.yml index 74b1af0..898e3f7 100644 --- a/roles/nginx/application/tasks/main.yml +++ b/roles/nginx/application/tasks/main.yml @@ -57,7 +57,7 @@ - name: Configure test file for validation directory copy: - content: "{{ ansible_fqdn }}" + content: "{{ inventory_hostname }}" dest: "{{ nginx_validation_test_file }}" owner: root group: root