Commit 0af94d10 by John Jarvis

moving hostname logic to the common role

parent 3038bb94
......@@ -18,7 +18,10 @@ COMMON_ENV_TYPE: 'default_type'
COMMON_PYPI_MIRROR_URL: 'https://pypi.python.org/simple'
# do not include http/https
COMMON_GIT_MIRROR: 'github.com'
# override this var to set a different hostname
COMMON_HOSTNAME: !!null
# override this var to add a prefix to the prompt
COMMON_PROMPT: ""
common_debian_pkgs:
......
......@@ -45,3 +45,21 @@
- name: common | Install logrotate configuration for edX
template: dest=/etc/logrotate.d/edx-services src=edx_logrotate.j2 owner=root group=root mode=644
- name: common | update /etc/hosts
template: src=hosts.j2 dest=/etc/hosts
when: common_hostname
register: etc_hosts
- name: common | update /etc/hostname
template: src=hostname.j2 dest=/etc/hostname
when: common_hostname
register: etc_hostname
- name: common | run hostname
shell: >
hostname -F /etc/hostname
when: common_hostname and (etc_hosts.changed or etc_hostname.changed)
- name: common | set global bashrc
template: src=bash.bashrc.j2 dest=/etc/bash.bashrc
# {{ ansible_managed }}
# System-wide .bashrc file for interactive bash(1) shells.
# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, overwrite the one in /etc/profile)
PS1='{{ hostname_prompt }}${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
# enable bash completion in interactive shells
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
# keep a full history log
if [ "$BASH_VERSINFO" -ge 2 ]; then
shopt -s cdspell
shopt -s checkwinsize
shopt -s cmdhist
shopt -s histappend
shopt -s checkhash
shopt -s no_empty_cmd_completion
shopt -s execfail
HISTFILESIZE=10000
HISTDIR="$HOME/.bash_histories/`uname -n`"
[[ ! -d $HISTDIR ]] && mkdir -p "$HISTDIR"
HISTFILE="$HISTDIR/`date +%Y_%m`"
# Suppress duplicates, bare "ls" and bg,fg and exit
HISTIGNORE="&:ls:[bf]g:exit"
fi
# sudo hint
if [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; then
case " $(groups) " in *\ admin\ *)
if [ -x /usr/bin/sudo ]; then
cat <<-EOF
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
EOF
fi
esac
fi
# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
function command_not_found_handle {
# check because c-n-f could've been removed in the meantime
if [ -x /usr/lib/command-not-found ]; then
/usr/bin/python /usr/lib/command-not-found -- "$1"
return $?
elif [ -x /usr/share/command-not-found/command-not-found ]; then
/usr/bin/python /usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "%s: command not found\n" "$1" >&2
return 127
fi
}
fi
---
# Simple role to change a hostname on an ubuntu server
- name: hostname | update /etc/hosts
template: src=hosts.j2 dest=/etc/hosts
register: etc_hosts
- name: hostname | update /etc/hostname
template: src=hostname.j2 dest=/etc/hostname
register: etc_hostname
- name: hostname | run hostname
shell: >
hostname -F /etc/hostname
when: etc_hosts.changed or etc_hostname.changed
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment