Merge "Add hostname role"

This commit is contained in:
Zuul 2019-03-28 16:37:05 +00:00 committed by Gerrit Code Review
commit f76efd0829
3 changed files with 33 additions and 0 deletions

View 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

View File

@ -28,6 +28,10 @@
include_role:
name: users
- name: Setup hostname role
include_role:
name: hostname
- name: Setup swap role
include_role:
name: swap

View 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] }}