hostname.yml 773 B

1234567891011121314151617181920212223242526
  1. ---
  2. - name: Setting Hostname Fact
  3. set_fact:
  4. new_hostname: "{{ custom_hostname | default(inventory_hostname_short) }}"
  5. - name: Setting FQDN Fact
  6. set_fact:
  7. new_fqdn: "{{ new_hostname }}.{{ openshift_openstack_full_dns_domain }}"
  8. - name: Setting hostname and DNS domain
  9. hostname: name="{{ new_fqdn }}"
  10. - name: Check for cloud.cfg
  11. stat: path=/etc/cloud/cloud.cfg
  12. register: cloud_cfg
  13. - name: Prevent cloud-init updates of hostname/fqdn (if applicable)
  14. lineinfile:
  15. dest: /etc/cloud/cloud.cfg
  16. state: present
  17. regexp: "{{ item.regexp }}"
  18. line: "{{ item.line }}"
  19. with_items:
  20. - { regexp: '^ - set_hostname', line: '# - set_hostname' }
  21. - { regexp: '^ - update_hostname', line: '# - update_hostname' }
  22. when: cloud_cfg.stat.exists == True