From 7952958172a98f5e07086e31defece72dfb260b1 Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Mon, 16 Mar 2015 16:18:42 -0500 Subject: [PATCH] Remove localdomain from rhel7 hostnames on setup This is a rhel7.0 specific thing so I moved it to it's own file as well as stopping firewalld which is also rhel7 specific. Signed-off-by: Andrew Schoen --- roles/common/tasks/redhat/rhel_7.0.yml | 20 ++++++++++++++++++++ roles/common/tasks/setup-redhat.yml | 9 ++++----- 2 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 roles/common/tasks/redhat/rhel_7.0.yml diff --git a/roles/common/tasks/redhat/rhel_7.0.yml b/roles/common/tasks/redhat/rhel_7.0.yml new file mode 100644 index 0000000..7621eba --- /dev/null +++ b/roles/common/tasks/redhat/rhel_7.0.yml @@ -0,0 +1,20 @@ +--- +- name: Stop firewalld + service: + name: firewalld + state: stopped + +- name: Get hostname. + command: hostname + register: existing_hostname + changed_when: false + +- name: Remove lab domain from hostname. + shell: hostname | cut -d'.' -f1 + register: new_hostname + when: existing_hostname.stdout.find("{{ lab_domain | mandatory }}") != -1 + +- name: Set hostname. + hostname: + name: "{{ new_hostname.stdout }}" + when: existing_hostname.stdout.find("{{ lab_domain | mandatory }}") != -1 diff --git a/roles/common/tasks/setup-redhat.yml b/roles/common/tasks/setup-redhat.yml index fdd1133..5e9f947 100644 --- a/roles/common/tasks/setup-redhat.yml +++ b/roles/common/tasks/setup-redhat.yml @@ -19,11 +19,6 @@ tags: - packages -- name: Stop firewalld - service: - name: firewalld - state: stopped - - name: Create remote.conf template: src: remote.conf @@ -31,3 +26,7 @@ group: root owner: root mode: 0644 + +- name: Include version specific tasks. + include: redhat/rhel_7.0.yml + when: ansible_distribution_version == "7.0" -- 2.39.5