Add hostname role
When we bootstrap a server, properly setup /etc/hosts. Change-Id: I265205f290d3fdc06d0b38aedaba9616cbe32520 Depends-On: https://review.openstack.org/648424 Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
parent
1bf6251c33
commit
274e778a37
24
playbooks/bootstrap/roles/hostname/tasks/main.yaml
Normal file
24
playbooks/bootstrap/roles/hostname/tasks/main.yaml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Copyright 2019 Red Hat, 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.
|
||||||
|
---
|
||||||
|
- name: Set system hostname
|
||||||
|
become: true
|
||||||
|
hostname:
|
||||||
|
name: "{{ inventory_hostname.split('.', 1)[0] }}"
|
||||||
|
|
||||||
|
- name: Create /etc/hosts
|
||||||
|
become: true
|
||||||
|
template:
|
||||||
|
dest: /etc/hosts
|
||||||
|
src: etc/hosts.j2
|
@ -28,6 +28,10 @@
|
|||||||
include_role:
|
include_role:
|
||||||
name: users
|
name: users
|
||||||
|
|
||||||
|
- name: Setup hostname role
|
||||||
|
include_role:
|
||||||
|
name: hostname
|
||||||
|
|
||||||
- name: Setup swap role
|
- name: Setup swap role
|
||||||
include_role:
|
include_role:
|
||||||
name: swap
|
name: swap
|
||||||
|
5
playbooks/bootstrap/templates/etc/hosts.j2
Normal file
5
playbooks/bootstrap/templates/etc/hosts.j2
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# This file is generated by Ansible
|
||||||
|
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
|
||||||
|
#
|
||||||
|
127.0.0.1 localhost
|
||||||
|
{{ hostvars[inventory_hostname].ansible_host }} {{ inventory_hostname }} {{ inventory_hostname.split('.', 1)[0] }}
|
Loading…
Reference in New Issue
Block a user