Initial commit
[ta/infra-ansible.git] / conflicts-with-openstack-ansible / hosts_config.yml
1 ---
2 # Copyright 2014, Rackspace US, Inc.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 # cmframework.requires: baremetal-interface-config.yml
16
17 - name: Setup /etc/hosts file
18   hosts: lxc_hosts
19   tasks:
20     - name: Fix /etc/hosts
21       lineinfile:
22         dest: /etc/hosts
23         state: present
24         line: "{{ hostvars[item]['ansible_host'] }} {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_hostname'].split('.')[0] }}"
25       with_items: "{{ groups['all'] }}"
26       when:
27         - item != 'localhost'
28     - name: Ensure localhost /etc/hosts entry is correct
29       lineinfile:
30         dest: /etc/hosts
31         state: present
32         line: '127.0.0.1 localhost'
33         regexp: '^127.0.0.1'