14 lines
345 B
YAML
14 lines
345 B
YAML
|
---
|
||
|
|
||
|
- name: "Setup the hostname of the target"
|
||
|
when: "new_hostname is defined"
|
||
|
block:
|
||
|
- ansible.builtin.hostname:
|
||
|
name: "{{ new_hostname }}"
|
||
|
|
||
|
- name: "Replace /etc/hosts old entries"
|
||
|
ansible.builtin.replace:
|
||
|
path: /etc/hosts
|
||
|
regexp: '^.*127\.0\.1\.1.*$'
|
||
|
replace: "127.0.1.1 {{ new_hostname }}"
|