Initial commit
This commit is contained in:
commit
e12d5eee5c
38
README.md
Normal file
38
README.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
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).
|
2
defaults/main.yml
Normal file
2
defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for MicroJoe.post-install
|
63
files/50-scw
Normal file
63
files/50-scw
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This file was copied from a Scaleway server and tweaked so that it does
|
||||||
|
# not depends on Scaleway-specific commands and file. It should run fine
|
||||||
|
# on non-Scaleway hosts.
|
||||||
|
|
||||||
|
export PATH="${PATH:+$PATH:}/bin:/usr/bin:/usr/local/bin"
|
||||||
|
|
||||||
|
[ -r /etc/lsb-release ] && . /etc/lsb-release
|
||||||
|
[ -r /etc/scw-release ] && . /etc/scw-release
|
||||||
|
if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
|
||||||
|
# Fall back to using the very slow lsb_release utility
|
||||||
|
DISTRIB_DESCRIPTION=$(lsb_release -s -d)
|
||||||
|
fi
|
||||||
|
|
||||||
|
date=`date`
|
||||||
|
load=`cat /proc/loadavg | awk '{print $1}'`
|
||||||
|
root_usage=`df -h / | awk '/\// {print $(NF-1)}'`
|
||||||
|
memory_usage=`free -m | awk '/Mem:/ { total=$2 } /buffers\/cache/ { used=$3 } END { printf("%3.1f%%", used/total*100)}'`
|
||||||
|
swap_usage=`free -m | awk '/Swap/ { printf("%3.1f%%", "exit !$2;$3/$2*100") }'`
|
||||||
|
users=`users | wc -w`
|
||||||
|
time=`uptime | grep -ohe 'up .*' | sed 's/,/\ hours/g' | awk '{ printf $2" "$3 }'`
|
||||||
|
processes=`ps aux | wc -l`
|
||||||
|
|
||||||
|
# Intermediate IP output for parsing public IPs (v4/v6)
|
||||||
|
ip=$(ip addr show $(ip route | grep default | cut -d' ' -f5))
|
||||||
|
|
||||||
|
# Global IPv4
|
||||||
|
ip4=$(echo "$ip" \
|
||||||
|
| grep "inet " \
|
||||||
|
| sed -e 's/^[ \t]*//' \
|
||||||
|
| cut -d' ' -f2 \
|
||||||
|
| cut -d/ -f1)
|
||||||
|
|
||||||
|
# Global IPv6
|
||||||
|
ip6=$(echo "$ip" \
|
||||||
|
| grep "inet6 " \
|
||||||
|
| grep "global" \
|
||||||
|
| sed -e 's/^[ \t]*//' \
|
||||||
|
| cut -d' ' -f2 \
|
||||||
|
| cut -d/ -f1)
|
||||||
|
|
||||||
|
KERNEL_VERSION=$(uname -r)
|
||||||
|
|
||||||
|
if [ -z "$IMAGE_DESCRIPTION" ]; then
|
||||||
|
source /etc/os-release
|
||||||
|
IMAGE_DESCRIPTION="$PRETTY_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "\n"
|
||||||
|
[ -f /etc/motd.head ] && cat /etc/motd.head || true
|
||||||
|
printf "\n"
|
||||||
|
printf "Welcome on %s (%s %s %s)\n" "${IMAGE_DESCRIPTION}" "$(uname -o)" "${KERNEL_VERSION}" "$(uname -m)"
|
||||||
|
printf "System information as of: %s\n" "$date"
|
||||||
|
printf "\n"
|
||||||
|
printf "IPv4 Address:\t%s\n" $ip4
|
||||||
|
printf "IPv6 Address:\t%s\n" $ip6
|
||||||
|
printf "\n"
|
||||||
|
printf "System load:\t%s\t\tMemory usage:\t%s\n" $load $memory_usage
|
||||||
|
printf "Usage on /:\t%s\t\tSwap usage:\t%s\n" $root_usage $swap_usage
|
||||||
|
printf "Local Users:\t%s\t\tProcesses:\t%s\n" $users $processes
|
||||||
|
printf "System uptime:\t%s %s\n" $time
|
||||||
|
[ -f /etc/motd.tail ] && cat /etc/motd.tail || true
|
2
handlers/main.yml
Normal file
2
handlers/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for MicroJoe.post-install
|
57
meta/main.yml
Normal file
57
meta/main.yml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
galaxy_info:
|
||||||
|
author: your name
|
||||||
|
description: your description
|
||||||
|
company: your company (optional)
|
||||||
|
|
||||||
|
# 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: license (GPLv2, CC-BY, etc)
|
||||||
|
|
||||||
|
min_ansible_version: 1.2
|
||||||
|
|
||||||
|
# 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:
|
||||||
|
|
||||||
|
#
|
||||||
|
# platforms is a list of platforms, and each platform has a name and a list of versions.
|
||||||
|
#
|
||||||
|
# platforms:
|
||||||
|
# - name: Fedora
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 25
|
||||||
|
# - name: SomePlatform
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 1.0
|
||||||
|
# - 7
|
||||||
|
# - 99.99
|
||||||
|
|
||||||
|
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.
|
39
tasks/main.yml
Normal file
39
tasks/main.yml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
---
|
||||||
|
# tasks file for MicroJoe.post-install
|
||||||
|
|
||||||
|
- name: Update and upgrade packages
|
||||||
|
apt:
|
||||||
|
update_cache: true
|
||||||
|
upgrade: true
|
||||||
|
|
||||||
|
- name: Install useful sysadmin tooling
|
||||||
|
apt:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: present
|
||||||
|
with_items:
|
||||||
|
- tmux
|
||||||
|
- htop
|
||||||
|
- tree
|
||||||
|
- vim
|
||||||
|
- mosh
|
||||||
|
- toilet
|
||||||
|
- figlet
|
||||||
|
|
||||||
|
- name: Install cool scaleway-inspirated motd script for non-scaleway hosts
|
||||||
|
copy:
|
||||||
|
src: 50-scw
|
||||||
|
dest: /etc/update-motd.d/50-scw
|
||||||
|
mode: 755
|
||||||
|
when: server_provider != "scaleway"
|
||||||
|
|
||||||
|
- name: Use alternative motd.head file
|
||||||
|
replace:
|
||||||
|
path: /etc/update-motd.d/50-scw
|
||||||
|
regexp: '^\[ -f \/etc\/motd\.head \] && cat \/etc\/motd\.head \|\| true$'
|
||||||
|
replace: "[ -f /etc/motd.head.alt ] && cat /etc/motd.head.alt || true"
|
||||||
|
backup: yes
|
||||||
|
|
||||||
|
- name: Generate cool motd.head
|
||||||
|
shell: toilet -f future -F metal $(hostname) > /etc/motd.head.alt
|
||||||
|
args:
|
||||||
|
creates: /etc/motd.head.alt
|
2
tests/inventory
Normal file
2
tests/inventory
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
5
tests/test.yml
Normal file
5
tests/test.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- MicroJoe.post-install
|
2
vars/main.yml
Normal file
2
vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for MicroJoe.post-install
|
Loading…
x
Reference in New Issue
Block a user