infra-ansible/roles/set_hostnames/tasks/main.yml
Ricardo Carrillo Cruz 682d0f14b4 Remove dependency from system-config
Instead of reusing system-config, just use Hiera as ENC
2015-08-12 11:11:06 +02:00

17 lines
570 B
YAML

---
# Set hostname and /etc/hosts
# Inspired by:
# https://github.com/ansible/ansible/pull/8482)
# https://gist.github.com/rothgar/8793800
- name: Set /etc/hostname
hostname: name="{{ inventory_hostname.split('.', 1)[0] }}"
# " lovely lonely double-quote for fixing vim highlighting
- name: Add all infra hosts to /etc/hosts
lineinfile: dest=/etc/hosts
line='{{ hostvars[item]['openstack']['private_v4'] }} {{ item }} {{ item.split('.', 1)[0] }}'
insertafter='^127\.0\.0\.1'
state=present
with_items: groups['infra']