diff options
author | Øystein Bedin <bedin@redhat.com> | 2016-06-17 14:48:37 -0400 |
---|---|---|
committer | Øystein Bedin <bedin@redhat.com> | 2016-06-17 14:48:37 -0400 |
commit | 3866232daed8ce1a48aa2db6f2f6c541e90756ec (patch) | |
tree | 8c49fc2769d3f6787393c210305021952bcf9298 /roles/hostnames/tasks/main.yaml | |
parent | 99d3622ec4ed9f150a77be9c42839cf5db19c43a (diff) | |
download | openshift-3866232daed8ce1a48aa2db6f2f6c541e90756ec.tar.gz openshift-3866232daed8ce1a48aa2db6f2f6c541e90756ec.tar.bz2 openshift-3866232daed8ce1a48aa2db6f2f6c541e90756ec.tar.xz openshift-3866232daed8ce1a48aa2db6f2f6c541e90756ec.zip |
Cleande up hostname role to make it more generic
Diffstat (limited to 'roles/hostnames/tasks/main.yaml')
-rw-r--r-- | roles/hostnames/tasks/main.yaml | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/roles/hostnames/tasks/main.yaml b/roles/hostnames/tasks/main.yaml index bf2fafb97..bb45445f5 100644 --- a/roles/hostnames/tasks/main.yaml +++ b/roles/hostnames/tasks/main.yaml @@ -1,27 +1,26 @@ --- - - name: Setting master(s) hostname - hostname: name="{% for thishost in groups['masters'] %}{% if inventory_hostname == thishost %}master{{ counter }}.{{ dns_domain }}{% endif %}{% set counter = counter + 1 %}{% endfor %}" - when: "'masters' in group_names" +- name: Setting Hostname Fact + set_fact: + new_hostname: "{{ custom_hostname | default(inventory_hostname) }}" - - name: Setting facts for masters - set_fact: ansible_hostname="{% for thishost in groups['masters'] %}{% if inventory_hostname == thishost %}master{{ counter }}{% endif %}{% set counter = counter + 1 %}{% endfor %}" - when: "'masters' in group_names" +- name: Setting FQDN Fact + set_fact: + new_fqdn: "{{ new_hostname }}.{{ dns_domain }}" - - name: Setting node(s) hostname - hostname: name="{% for thishost in groups['nodes'] %}{% if inventory_hostname == thishost %}node{{ counter }}.{{ dns_domain }}{% endif %}{% set counter = counter + 1 %}{% endfor %}" - when: "'nodes' in group_names" +- name: Setting hostname and DNS domain + hostname: name="{{ new_fqdn }}" - - name: Setting facts for nodes - set_fact: ansible_hostname="{% for thishost in groups['nodes'] %}{% if inventory_hostname == thishost %}node{{ counter }}{% endif %}{% set counter = counter + 1 %}{% endfor %}" - when: "'nodes' in group_names" +- name: Check for cloud.cfg + stat: path=/etc/cloud/cloud.cfg + register: cloud_cfg - - name: "Templating records" - become: false - template: - src: "{{ role_path }}/templates/records.template.yaml" - dest: "/tmp/records.yaml" - force: yes - delegate_to: localhost - - - name: "Updating hostname facts" - setup: filter=ansible_hostname +- name: Prevent cloud-init updates of hostname/fqdn (if applicable) + lineinfile: + dest: /etc/cloud/cloud.cfg + state: present + regexp: "{{ item.regexp }}" + line: "{{ item.line }}" + with_items: + - { regexp: '^ - set_hostname', line: '# - set_hostname' } + - { regexp: '^ - update_hostname', line: '# - update_hostname' } + when: cloud_cfg.stat.exists == True |