Extracted the basic role from the madonsible playbook
This commit is contained in:
29
.travis.yml
Normal file
29
.travis.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
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/
|
||||
38
README.md
Normal file
38
README.md
Normal file
@@ -0,0 +1,38 @@
|
||||
Basic role for all of madonius' home server
|
||||
=========
|
||||
|
||||
Does the basic stuff you expect a role to do
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
This role expect the machine to be a debian machine.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
None
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
None
|
||||
|
||||
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
|
||||
------------------
|
||||
|
||||
© Madonius 2016
|
||||
2
defaults/main.yml
Normal file
2
defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# defaults file for basic
|
||||
0
files/etc/vim/vimrc
Normal file
0
files/etc/vim/vimrc
Normal file
1
files/public_keys/madonius
Normal file
1
files/public_keys/madonius
Normal file
@@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/4K5CJyIeBlRO9La6Pm1ZAbjknW+VR1xLOA0QnHNLIecnSyCLS0Gr0xro+o3L4hX8XLDhmfu9LzV+Ih78C0LT2dISXwhnqPXu72QqlzOR/qsCHwhjt8x7tHL3jjLW/J85bljCq+JahyfgzneaoXw36QtHYObh1TFJVCGAivyh6Z/XYGIKqiecgO5r/hQM7UOwOnHmtw8YbowsaV+iQh5dIDjW0lpzx1tXuGi22xB/QXmA7bOEYRt50ZrMYFud2Sc7IlyKsYLahEEAhUPrXJ83ij7j71itnns09tTb6eBCpjFYzVlpTZfPWz1nNHTkOhfqg41+lBjQeDffH6ZvECnz madonius@Brorsen
|
||||
2
handlers/main.yml
Normal file
2
handlers/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# handlers file for basic
|
||||
27
meta/main.yml
Normal file
27
meta/main.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
galaxy_info:
|
||||
author: Emmanouil Kampitakis
|
||||
description: Base class for the home infrastructure
|
||||
company: Hometech Hometechnologies for the Homes of homies
|
||||
|
||||
license: GPLv3
|
||||
|
||||
min_ansible_version: 2.1
|
||||
|
||||
platforms:
|
||||
- name: Debian
|
||||
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.
|
||||
11
sample_user_definition.yml
Normal file
11
sample_user_definition.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
users:
|
||||
- name: madonius
|
||||
ssh-key: dsa1024 hypersecurekey
|
||||
uid:
|
||||
shell: /bin/zsh
|
||||
comment:
|
||||
groups:
|
||||
- sudo
|
||||
- webadmin
|
||||
- banana
|
||||
|
||||
27
tasks/apt.yml
Normal file
27
tasks/apt.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
- name: Update the installed packages
|
||||
apt:
|
||||
update_cache: yes
|
||||
upgrade: yes
|
||||
become: true
|
||||
|
||||
- name: Install essential packages
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
become: true
|
||||
with_items:
|
||||
- vim
|
||||
- emacs
|
||||
- git
|
||||
- htop
|
||||
- zsh
|
||||
- python
|
||||
- python3
|
||||
- screen
|
||||
- tmux
|
||||
- dnsutils
|
||||
- stow
|
||||
- mosh
|
||||
- fail2ban
|
||||
- tig
|
||||
15
tasks/main.yml
Normal file
15
tasks/main.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
# tasks file for basic
|
||||
- name: Make apt stuff
|
||||
include: apt.yml
|
||||
tags:
|
||||
- apt
|
||||
|
||||
- name: Configure users
|
||||
include: users.yml
|
||||
loop: "{{ basic_users }}"
|
||||
loop_control:
|
||||
loop_var: os_user
|
||||
|
||||
- name: Setup sudo access
|
||||
include: sudo.yml
|
||||
8
tasks/sudo.yml
Normal file
8
tasks/sudo.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: Give sudo group passwordless sudo
|
||||
lineinfile:
|
||||
dest: /etc/sudoers
|
||||
regexp: "^%sudo"
|
||||
line: "%sudo ALL=(ALL) NOPASSWD: ALL"
|
||||
tags: sudo
|
||||
become: true
|
||||
16
tasks/users.yml
Normal file
16
tasks/users.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
- name: "Add user {{ os_user.name }}"
|
||||
user:
|
||||
name: "{{ os_user.name }}"
|
||||
comment: "{{ os_user.comment }}"
|
||||
uid: "{{ os_user.uid }}"
|
||||
shell: "{{ os_user.shell }}"
|
||||
groups: "{{ os_user.groups }}"
|
||||
state: "{{ os_user.state }}"
|
||||
become: true
|
||||
|
||||
- name: Copy local ssh key to authorized keys file
|
||||
authorized_key:
|
||||
user: "{{ os_user.name }}"
|
||||
key: "{{ os_user.ssh_auth_key }}"
|
||||
become: true
|
||||
@@ -0,0 +1,3 @@
|
||||
# Generated by Vagrant
|
||||
|
||||
default ansible_host=127.0.0.1 ansible_port=2222 ansible_user='vagrant' ansible_ssh_private_key_file='/home/madonius/.vagrant.d/insecure_private_key'
|
||||
10
tests/Vagrantfile
vendored
Normal file
10
tests/Vagrantfile
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
Vagrant.configure(2) do |config|
|
||||
config.vm.hostname = "vagrant.example.com"
|
||||
config.vm.box = "debian/stretch64"
|
||||
config.ssh.insert_key = false
|
||||
|
||||
config.vm.provision "ansible" do |ansible|
|
||||
ansible.verbose ="vv"
|
||||
ansible.playbook = "test.yml"
|
||||
end
|
||||
end
|
||||
2
tests/ansible.cfg
Normal file
2
tests/ansible.cfg
Normal file
@@ -0,0 +1,2 @@
|
||||
[defaults]
|
||||
roles_path=../../
|
||||
1
tests/inventory
Normal file
1
tests/inventory
Normal file
@@ -0,0 +1 @@
|
||||
10.0.0.100
|
||||
13
tests/test.yml
Normal file
13
tests/test.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
- hosts: all
|
||||
roles:
|
||||
- role: basic
|
||||
basic_users:
|
||||
- name: madonius
|
||||
comment: 'madonius'
|
||||
uid: 1337
|
||||
shell: /bin/zsh
|
||||
groups: sudo
|
||||
state: present
|
||||
ssh_auth_key: >
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB3HexVmU/vTVFUFk2AAB1h3mOOrfFPt1Gq2cBldaYnn madonius@iapeptus
|
||||
2
vars/main.yml
Normal file
2
vars/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# vars file for basic
|
||||
Reference in New Issue
Block a user