From eafe632a5d4654f7c5438c137c170ee7cbfad2b5 Mon Sep 17 00:00:00 2001 From: Adham Helal Date: Wed, 18 Jan 2017 15:13:04 +0100 Subject: [PATCH] Support redhat aws bullshit --- ansible 2.cfg | 1 + tasks/main.yml | 6 ++++++ tasks/redhat.yml | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 120000 ansible 2.cfg create mode 100644 tasks/redhat.yml diff --git a/ansible 2.cfg b/ansible 2.cfg new file mode 120000 index 0000000..4bde64f --- /dev/null +++ b/ansible 2.cfg @@ -0,0 +1 @@ +test/ansible.cfg \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index 7e09c0f..f548325 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,3 +1,5 @@ +--- + - name: Temp override for "hostname_fqdn" set_fact: hostname_fqdn : "{{ inventory_hostname }}" @@ -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" \ No newline at end of file diff --git a/tasks/redhat.yml b/tasks/redhat.yml new file mode 100644 index 0000000..1046a1a --- /dev/null +++ b/tasks/redhat.yml @@ -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 }}"