initial commit
This commit is contained in:
33
tasks/set_hostname.yaml
Normal file
33
tasks/set_hostname.yaml
Normal file
@ -0,0 +1,33 @@
|
||||
---
|
||||
|
||||
- name: Get Old Hostname
|
||||
shell: hostname
|
||||
register: old_hostname
|
||||
|
||||
- name: set prop_hostname
|
||||
set_fact:
|
||||
prop_hostname: "{{ new_hostname }}"
|
||||
|
||||
- name: Add domain
|
||||
set_fact:
|
||||
prop_hostname: "{{ new_hostname }}.home.cosmos"
|
||||
when: add_domain | bool
|
||||
|
||||
- name: Display hostname info
|
||||
debug:
|
||||
msg:
|
||||
- "Old hostname was {{ old_hostname.stdout_lines[0] }}"
|
||||
- "New hostname will be {{ prop_hostname }}"
|
||||
|
||||
- name: Rename Endpoint
|
||||
hostname:
|
||||
name: "{{ prop_hostname }}"
|
||||
|
||||
- name: Add FQDN to hosts file
|
||||
lineinfile:
|
||||
path: /etc/hosts
|
||||
regexp: '{{ old_hostname.stdout_lines[0] }}'
|
||||
line: '127.0.0.1 {{ prop_hostname }}'
|
||||
|
||||
|
||||
...
|
||||
Reference in New Issue
Block a user