Skip to content

Commit

Permalink
Support redhat aws bullshit
Browse files Browse the repository at this point in the history
  • Loading branch information
ahelal committed Jan 18, 2017
1 parent 674bd04 commit eafe632
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions ansible 2.cfg
6 changes: 6 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

- name: Temp override for "hostname_fqdn"
set_fact:
hostname_fqdn : "{{ inventory_hostname }}"
Expand Down Expand Up @@ -39,3 +41,7 @@
state: present
unsafe_writes: "{{ hostname_safe_write }}"
with_items: "{{hostname_hosts_file}}"

- name: Include redhat
include: redhat.yml
when: ansible_os_family == "RedHat"
34 changes: 34 additions & 0 deletions tasks/redhat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---

- name: redhat | check /etc/sysconfig/network
stat:
path="/etc/sysconfig/network"
get_md5="no"
get_checksum="no"
register: hostname_network_file

- name: redhat | check /etc/sysconfig/network
lineinfile:
dest="/etc/sysconfig/network"
regexp="^HOSTNAME="
line="HOSTNAME={{ inventory_hostname.split(".")[0] }}"
state="present"
unsafe_writes="{{ hostname_safe_write }}"
when: "{{ hostname_network_file.stat.exists }}"

- name: redhat | check /etc/cloud/cloud.cfg
stat:
path="/etc/cloud/cloud.cfg"
get_md5="no"
get_checksum="no"
register: hostname_network_file

- name: redhat | check /etc/cloud/cloud.cfg
lineinfile:
dest: "/etc/cloud/cloud.cfg"
regexp: "preserve_hostname"
line: 'preserve_hostname: true'
insertafter: "EOF"
state: "present"
unsafe_writes: "{{ hostname_safe_write }}"
when: "{{ hostname_network_file.stat.exists }}"

0 comments on commit eafe632

Please sign in to comment.