Commit 4347ea1d authored by Tobias Stein's avatar Tobias Stein
Browse files

Initial commit

parents
---
language: python
python: "2.7"
# Use the new container infrastructure
sudo: false
# Install ansible
addons:
apt:
packages:
- python-pip
install:
# Install ansible
- pip install ansible
# Check ansible version
- ansible --version
# Create ansible.cfg with correct roles_path
- printf '[defaults]\nroles_path=../' >ansible.cfg
script:
# Basic role syntax check
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
\ No newline at end of file
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
---
ansible_nopasswd: False
repo_defaults:
core:
debian:
allowed_suffixes:
- null
- updates
- backports
- security
type:
- deb
- deb-src
url:
base: "http://ftp2.de.debian.org/debian/"
security: "http://security.debian.org/debian-security/"
archive: "http://archive.debian.org/debian/"
components:
- main
- contrib
- non-free
code_names:
wheezy:
release_number: 7
archive: true
release_suffixes:
- suffix: null
- suffix: backports
- suffix: backports-sloppy
jessie: &OLDOLDSTABLE
release_number: 8
archive: false
release_suffixes:
- suffix: null
- suffix: updates
security_suffixes:
- suffix: null
subdir: updates
stretch: &OLDSTABLE
release_number: 9
archive: false
release_suffixes:
- suffix: null
- suffix: backports
- suffix: backports-sloppy
- suffix: updates
- suffix: proposed-updates
security_suffixes:
- suffix: null
subdir: updates
buster: &STABLE
release_number: 10
archive: false
release_suffixes:
- suffix: null
- suffix: backports
- suffix: updates
- suffix: proposed-updates
security_suffixes:
- suffix: null
subdir: updates
bullseye: &TESTING
release_number: 11
archive: false
release_suffixes:
- suffix: null
- suffix: backports
- suffix: updates
- suffix: proposed-updates
security_suffixes:
- suffix: security
- suffix: security
subdir: updates
sid: &UNSTABLE
archive: false
release_suffixes:
- suffix: null
suite_names:
oldoldstable: *OLDOLDSTABLE
oldstable: *OLDSTABLE
stable: *STABLE
testing: *TESTING
unstable: *UNSTABLE
experimental:
archive: false
release_suffixes:
- suffix: null
package_set:
core:
debian:
standard: [
apt-file, apt-transport-https, aptitude, bash-completion, ca-certificates, curl,
dmidecode, dosfstools, git, htop, iftop, info, iotop, jq, libcrack2, locales,
lsb-release, lsof, man-db, mc, mlocate, openssl, parted, pigz, psmisc, pv,
pwgen, python-apt, python3-apt, rsync, screen, sqlite3, ssl-cert, strace, sudo,
sysstat, tmux, vim, wget, zsh ]
extra: [ btrfs-progs ]
#aliases:
# - name: 'root'
# rhs:
# - "root@domain.tld"
# vim: et:noai:ts=2:sw=2
# ~/.bashrc: executed by bash(1) for non-login shells.
# Note: PS1 and umask are already set in /etc/profile. You should not
# need this unless you want different defaults for root.
# PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
umask 022
# You may uncomment the following lines if you want `ls' to be colorized:
export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
alias ..='cd ..'
alias ...='cd ../..'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# Some more alias to avoid making mistakes:
# alias rm='rm -i'
# alias cp='cp -i'
# alias mv='mv -i'
" All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by
" the call to :runtime you can find below. If you wish to change any of those
" settings, you should do it in this file (/etc/vim/vimrc), since debian.vim
" will be overwritten everytime an upgrade of the vim packages is performed.
" It is recommended to make changes after sourcing debian.vim since it alters
" the value of the 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim
" Vim will load $VIMRUNTIME/defaults.vim if the user does not have a vimrc.
" This happens after /etc/vim/vimrc(.local) are loaded, so it will override
" any settings in these files.
" If you don't want that to happen, uncomment the below line to prevent
" defaults.vim from being loaded.
let g:skip_defaults_vim = 1
" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
syntax on
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
set background=dark
" Uncomment the following to have Vim jump to the last position when
" reopening a file
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
filetype plugin indent on
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
"set ignorecase " Do case insensitive matching
"set smartcase " Do smart case matching
"set incsearch " Incremental search
"set autowrite " Automatically save before commands like :next and :make
"set hidden " Hide buffers when they are abandoned
"set mouse=a " Enable mouse usage (all modes)
---
# handlers file for base
- name: restart cron
become: true
service:
name: cron
state: restarted
- name: trigger udev
become: true
command: udevadm trigger
- name: update grub2
become: true
command: update-grub2
- name: newaliases
become: true
command: newaliases
galaxy_info:
author: "Tobias Stein"
description: "Configure basic Linux OS properties"
company: Rockstable IT
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: GPLv2+
min_ansible_version: 2.4
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
# Optionally specify the branch Galaxy will use when accessing the GitHub
# repo for this role. During role install, if no tags are available,
# Galaxy will use this branch. During import Galaxy will access files on
# this branch. If Travis integration is configured, only notifications for this
# branch will be accepted. Otherwise, in all cases, the repo's default branch
# (usually master) will be used.
#github_branch:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - 1.0
# - 7
# - 99.99
- name: Debian
versions:
- all
- name: Ubuntu
versions:
- all
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
---
### VIM
- name: "vim - configure vimrc.local"
become: true
copy:
src: vimrc.local
dest: /etc/vim/vimrc.local
owner: root
group: root
mode: 0644
tags:
- vim
- vimrc.local
### BASH
- name: "bash - configure /root/.bashrc"
become: true
copy:
src: bashrc
dest: /root/.bashrc
owner: root
group: root
mode: 0640
tags:
- bash
- bashrc
### ZSH
- name: "zsh - grml-config"
become: true
git:
repo: 'git://git.grml.org/grml-etc-core.git'
dest: /opt/grml-etc-core
version: HEAD
tags:
- grml
- zsh
- zshrc
- name: "zsh - stat '/etc/zsh'"
stat:
path: /etc/zsh
register: etc_zsh
- name: "zsh - debug variable 'etc_zsh'"
debug:
var: etc_zsh
verbosity: 2
when: etc_zsh.stat.exists
tags:
- debug
- debug:
msg: "zsh - path /etc/zsh exists and is a symlink"
verbosity: 2
when:
- etc_zsh.stat.islnk is defined
- etc_zsh.stat.islnk
tags:
- debug
- debug:
msg: "zsh - path '/etc/zsh' exists and isn't a symlink"
verbosity: 2
when:
- etc_zsh.stat.islnk is defined
- not etc_zsh.stat.islnk
- name: "zsh - move '/etc/zsh' to '/etc/zsh.dist'"
become: true
command: mv -v /etc/zsh /etc/zsh.dist
when:
- etc_zsh.stat.islnk is defined
- not etc_zsh.stat.islnk
register: etc_zsh_mv
- name: "zsh - debug variable 'etc_zsh_mv'"
debug:
var: etc_zsh_mv
verbosity: 2
when: etc_zsh_mv.changed
- name: "zsh - sym-link '/etc/zsh' to '/opt/grml-etc-core/etc/zsh'"
become: true
file:
src: /opt/grml-etc-core/etc/zsh
path: /etc/zsh
state: link
owner: root
group: root
when:
- etc_zsh_mv.changed
- etc_zsh_mv.failed is defined
- not etc_zsh_mv.failed
- name: "zsh - stat /etc/zsh"
stat:
path: /etc/zsh
register: etc_zsh
- name: "Show variable 'etc_zsh'"
debug:
var: etc_zsh
verbosity: 2
when: etc_zsh.stat.exists
- name: "zsh - make zsh default shell for selected users"
become: true
user:
name: "{{ item }}"
shell: "/bin/zsh"
loop:
- tobias
when:
- etc_zsh.stat.exists is defined
- etc_zsh.stat.exists
# vim: et:noai:ts=2:sw=2
---
#- name: "Debug hostvars as message"
# debug:
# msg: |
# "{{ item.key }}"
# "{{ item.value }}"
# verbosity: 2
# with_dict: "{{ hostvars[inventory_hostname] }}"
# when: >
# debug
# tags:
# - debug_hostvars_msg
- name: "Debug hostvars as var"
debug:
var: hostvars[inventory_hostname]
verbosity: 2
when: >
debug
tags:
- debug_hostvars_var
# vim: et:noai:ts=2:sw=2
---
- name: "Kernel - adjust config via sysctl"
become: true
sysctl:
name: "{{ item.name }}"
value: "{{ item.value }}"
state: "{{ item.state }}"
reload: "{{ item.reload|default(true) }}"
sysctl_file: "{{ item.sysctl_file }}"
when: linux_sysctl is defined
loop: "{{ linux_sysctl }}"
tags:
- kernel
- sysctl
# vim: et:noai:ts=2:sw=2
---
### main.yml is entry point to role "base"
- import_tasks: debug.yml
tags:
- debug_hostvars
- name: "Combine 'repo_defaults' with user defined 'repo' recursively"
set_fact:
repo: >
{{ repo_defaults
|combine(repo|default({}), recursive=True) }}
tags:
- repo_combine
- base_prepare
- import_tasks: os.yml
tags:
- operating_system
- os
- import_tasks: package_management.yml
tags:
- package_management
- pm
- apt
- import_tasks: package_actions.yml
tags:
- package_actions
- pa
- import_tasks: configure_tools.yml
tags:
- tools
- import_tasks: kernel.yml
tags:
- kernel
- linux
- import_tasks: security.yml
tags:
- security
# vim: et:noai:ts=2:sw=2
---
### OPERATING SYSTEM CONFIGURATION
- name: "OS - allow ansible user to use sudo without password (only for testing)"
become: true
template:
src: sudoers.d/ansible.jn2
dest: "/etc/sudoers.d/ansible"
owner: root
group: root
mode: '0440'
lstrip_blocks: true
backup: no
validate: /usr/sbin/visudo -cf %s
when: ansible_nopasswd
tags:
- ansible_nopasswd
- name: "OS - make sure to remove sudo without password (only for testing)"
become: true
file:
path: "/etc/sudoers.d/ansible"
state: absent
when: not ansible_nopasswd
tags:
- ansible_nopasswd
- name: "OS - configure hostname"
hostname:
name: "{{ inventory_hostname_short }}"
tags:
- hostname
- name: "OS - adjust timezones of hardware and system clock"
timezone:
hwclock: UTC
name: Europe/Berlin
notify:
- restart cron
tags:
- timezone
- name: "OS - ensure a locale 'de_DE.UTF-8' exists"
locale_gen:
name: de_DE.UTF-8
state: present
#- name: "OS - Configure '/etc/hosts'"
# hostname:
# name: "{{ ansible_hostname }}"
### IO-SCHEDULER
- name: "OS - get name of io-scheduler (noop/none)"
check_mode: no
failed_when: False
changed_when: False
shell:
cmd: >
grep -oh -e 'none' -e 'noop' "{{ item }}" 2>/dev/null
register: scheduler
loop:
- /sys/class/block/vda/queue/scheduler
- /sys/class/block/sda/queue/scheduler
when: ansible_virtualization_role == "guest"
tags:
- io_scheduler
- name: "OS - setfact io_scheduler"
vars:
query: '[? stdout ].stdout'
set_fact:
io_scheduler: "{{ item }}"
when:
- ansible_virtualization_role == "guest"
loop: "{{ scheduler.results|json_query(query) }}"
tags:
- debug
- io_scheduler
- name: "OS - configure io-scheduler"
become: true
template:
src: "60-persistent-storage-scheduler.rules.jn2"
dest: "/etc/udev/rules.d/60-persistent-storage-scheduler.rules"
owner: root