Initial commit
[ta/infra-ansible.git] / conflicts-with-openstack-ansible / hosts_config.yml
diff --git a/conflicts-with-openstack-ansible/hosts_config.yml b/conflicts-with-openstack-ansible/hosts_config.yml
new file mode 100644 (file)
index 0000000..9e6970f
--- /dev/null
@@ -0,0 +1,33 @@
+---
+# Copyright 2014, Rackspace US, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# cmframework.requires: baremetal-interface-config.yml
+
+- name: Setup /etc/hosts file
+  hosts: lxc_hosts
+  tasks:
+    - name: Fix /etc/hosts
+      lineinfile:
+        dest: /etc/hosts
+        state: present
+        line: "{{ hostvars[item]['ansible_host'] }} {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_hostname'].split('.')[0] }}"
+      with_items: "{{ groups['all'] }}"
+      when:
+        - item != 'localhost'
+    - name: Ensure localhost /etc/hosts entry is correct
+      lineinfile:
+        dest: /etc/hosts
+        state: present
+        line: '127.0.0.1 localhost'
+        regexp: '^127.0.0.1'