mirror of
https://github.com/famedly/ansible-collection-base
synced 2024-11-10 06:24:17 +00:00
fix(hostname): resolve lints
This commit is contained in:
parent
dd88cbb1ab
commit
8f2b50353a
4 changed files with 17 additions and 24 deletions
|
@ -1,4 +1,2 @@
|
|||
---
|
||||
|
||||
hostname_extra_hosts: []
|
||||
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
---
|
||||
|
||||
- name: Set /etc/hostname to FQDN of the server
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/hostname
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
content: |
|
||||
{{ hostname_fqdn }}
|
||||
tags: [ 'deploy', 'deploy-hostname' ]
|
||||
|
||||
tags: [deploy, deploy-hostname]
|
||||
- name: Ensure /etc/hosts contains all hostnames and aliases of the server
|
||||
blockinfile:
|
||||
ansible.builtin.blockinfile:
|
||||
dest: /etc/hosts
|
||||
owner: root
|
||||
group: root
|
||||
|
@ -21,22 +19,20 @@
|
|||
{{ host.ip }} {{ host.fqdn }} {{ host.alias | default([]) | join(" ") }}
|
||||
{% endfor %}
|
||||
marker: "# {mark} ANSIBLE MANAGED BLOCK"
|
||||
tags: [ 'deploy', 'deploy-hostname' ]
|
||||
|
||||
tags: [deploy, deploy-hostname]
|
||||
# Needed because ansibles `ansible_fqdn` is loaded
|
||||
# from /etc/hostname, not from the running hostname
|
||||
- name: Query current hostname
|
||||
command:
|
||||
cmd: "hostname"
|
||||
ansible.builtin.command:
|
||||
cmd: hostname
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
register: current_hostname
|
||||
tags: [ 'deploy', 'deploy-hostname' ]
|
||||
|
||||
tags: [deploy, deploy-hostname]
|
||||
- name: Set hostname via hostnamectl to avoid a reboot
|
||||
command:
|
||||
cmd: "hostnamectl set-hostname {{ hostname_fqdn }}"
|
||||
ansible.builtin.command:
|
||||
cmd: hostnamectl set-hostname {{ hostname_fqdn }}
|
||||
when: hostname_fqdn != hostname_current
|
||||
vars:
|
||||
hostname_current: "{{ current_hostname.stdout }}."
|
||||
tags: [ 'deploy', 'deploy-hostname' ]
|
||||
tags: [deploy, deploy-hostname]
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
|
||||
hostname_localhost:
|
||||
ip: 127.0.0.1
|
||||
fqdn: "localhost.localdomain"
|
||||
alias: [ "localhost" ]
|
||||
hostname_hosts: "{{ [ hostname_localhost ] + hostname_extra_hosts }}"
|
||||
fqdn: localhost.localdomain
|
||||
alias: [localhost]
|
||||
hostname_hosts: "{{ [hostname_localhost] + hostname_extra_hosts }}"
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
---
|
||||
- name: Ensure Pip is installed.
|
||||
package:
|
||||
ansible.builtin.package:
|
||||
name: "{{ pip_package_name }}"
|
||||
state: present
|
||||
|
||||
- name: Install packages from list
|
||||
pip:
|
||||
ansible.builtin.pip:
|
||||
name: "{{ item.name | default(item) }}"
|
||||
version: "{{ item.version | default(omit) }}"
|
||||
virtualenv: "{{ item.virtualenv | default(omit) }}"
|
||||
|
@ -16,7 +16,7 @@
|
|||
environment: "{{ pip_environment_variables }}"
|
||||
|
||||
- name: Install packages from requirements file
|
||||
pip:
|
||||
ansible.builtin.pip:
|
||||
requirements: "{{ pip_requirements_file }}"
|
||||
virtualenv: "{{ pip_package_virtualenv | default(omit) }}"
|
||||
state: "{{ pip_package_state | default(omit) }}"
|
||||
|
|
Loading…
Reference in a new issue