Files
ansible-role-common/tasks/hostname.yml
2018-10-26 23:53:09 +02:00

28 lines
522 B
YAML

---
- name: check hostname
command: hostname
register: hostname
changed_when: False
- name: set hostname
command: hostname "{{ inventory_hostname_short }}"
when: hostname.stdout != inventory_hostname_short
ignore_errors: yes
- name: /etc/hostname
copy:
dest: /etc/hostname
content: "{{ inventory_hostname_short }}\n"
owner: root
group: root
mode: 0644
backup: yes
- name: /etc/hosts
template:
dest: /etc/hosts
src: hosts.j2
owner: root
group: root
mode: 0644