Second commit

This commit is contained in:
Elijah Lazkani 2018-05-27 23:01:28 -04:00
commit 33ed1c69f0
24 changed files with 435 additions and 0 deletions

106
.gitignore vendored Normal file
View file

@ -0,0 +1,106 @@
*.retry
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/

4
Ansible/pleasure.yml Normal file
View file

@ -0,0 +1,4 @@
- hosts: local
become: yes
roles:
- base

View file

@ -0,0 +1,13 @@
extends: default
rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
line-length: disable
# NOTE(retr0h): Templates no longer fail this lint rule.
# Uncomment if running old Molecule templates.
# truthy: disable

View file

@ -0,0 +1,5 @@
---
common_repo_package_list:
- git
- fish
- vim-enhanced

View file

@ -0,0 +1,7 @@
---
user: elijah
user_home: "/home/{{ user }}"
workdir_path: "{{ user_home }}/sandbox"
virtualenvs_path: "{{ user_home }}/.virtualenvs"
omf_git_repo: https://github.com/oh-my-fish/oh-my-fish

View file

@ -0,0 +1,5 @@
---
common_repo_package_list:
- git
- fish
- vim

View file

@ -0,0 +1 @@
---

View file

@ -0,0 +1,64 @@
---
galaxy_info:
author: Elijah Lazkani
description: DevOps Engineer
# 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: BSD
min_ansible_version: 2.5
# 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
platforms:
- name: Febora
versions:
- 28
- name: Ubuntu
versions:
- bionic
#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.

View file

@ -0,0 +1,14 @@
# Molecule managed
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi

View file

@ -0,0 +1,16 @@
*******
Install
*******
Requirements
============
* Docker Engine
* docker-py
Install
=======
.. code-block:: bash
$ sudo pip install docker-py

View file

@ -0,0 +1,22 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: Fedora
image: fedora:28
- name: Ubuntu
image: ubuntu:bionic
provisioner:
name: ansible
lint:
name: ansible-lint
scenario:
name: default
verifier:
name: testinfra
lint:
name: flake8

View file

@ -0,0 +1,11 @@
---
- name: Converge
hosts: all
pre_tasks:
- name: Create user "{{ user }}"
user:
name: "{{ user }}"
home: "{{ user_home }}"
state: present
roles:
- role: base

View file

@ -0,0 +1,14 @@
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_hosts_file(host):
f = host.file('/etc/hosts')
assert f.exists
assert f.user == 'root'
assert f.group == 'root'

View file

@ -0,0 +1,14 @@
---
- name: Create work directory
file:
path: "{{ workdir_path }}"
owner: "{{ user }}"
group: "{{ user }}"
state: directory
- name: Create virtualenvs directory
file:
path: "{{ virtualenvs_path }}"
owner: "{{ user }}"
group: "{{ user }}"
state: directory

View file

@ -0,0 +1,5 @@
---
- name: Install Fedora packages
dnf:
name: "{{ common_repo_package_list }}"
state: latest

View file

@ -0,0 +1,25 @@
---
- name: Download Oh My Fish
git:
repo: "{{ omf_git_repo }}"
dest: "{{ workdir_path }}/omf"
become: yes
become_user: "{{ user }}"
- name: Set user's default shell
user:
name: "{{ user }}"
shell: /usr/bin/fish
- stat:
path: "{{ user_home }}/.local/share/omf"
register: omf_config_stat_result
- name: Install Oh My Fish
shell: ./install --noninteractive
args:
executable: /usr/bin/fish
chdir: "{{ workdir_path }}/omf/bin/"
when: omf_config_stat_result.stat.exists == False
become: yes
become_user: "{{ user }}"

View file

@ -0,0 +1,30 @@
---
- name: gather os specific variables
include_vars: "{{ item }}"
with_first_found:
- "../defaults/{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | int }}.yml"
- "../defaults/{{ ansible_distribution | lower }}.yml"
- "../defaults/{{ ansible_os_family | lower }}.yml"
- "../defaults/defaults.yml"
tags: variables
- include_tasks: "{{ item }}"
with_first_found:
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | int }}.yml"
- "{{ ansible_distribution | lower }}.yml"
- "{{ ansible_os_family | lower }}.yml"
- defaults.yml
- name: Get passwd file
shell: grep -r "^{{ user }}" /etc/passwd
register: grep_user
failed_when: false
- block:
- name: Apply common tasks
include_tasks: common.yml
- name: Applying fish tasks
include_tasks: fish.yml
when: grep_user.stdout

View file

@ -0,0 +1,5 @@
---
- name: Install Ubuntu packages
apt:
name: "{{ common_repo_package_list }}"
state: latest

View file

@ -0,0 +1 @@
---

25
LICENSE Normal file
View file

@ -0,0 +1,25 @@
BSD 2-Clause License
Copyright (c) 2018, Elijah Lazkani
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

4
README.md Normal file
View file

@ -0,0 +1,4 @@
# Solid State Subether
This is my personal repository for bootstrapping machines with [Ansible](https://www.ansible.com) for my own use.
These types of repositories are generally called dotfile repositories.

39
bootstrap.sh Executable file
View file

@ -0,0 +1,39 @@
#!/bin/bash
# This script will bootstrap the machine using Ansible
# Copyright (C) 2018 Elijah Lazkani
playbook=$1
function _find_ansible() {
command ansible-playbook -h > /dev/null 2>&1
if [[ $? -ne 0 ]];
then
echo "Ansible not found..."
exit 1
fi
}
function _ansible () {
_find_ansible
echo "Bootstrapping Ansible"
if [[ $playbook ]];
then
if [ ! -f inventory ];
then
echo "Inventory file not found"
touch inventory
fi
echo "Sit down, relax and kick your legs up, fun is about to begin..."
ansible-playbook -i inventory Ansible/$playbook --ask-sudo-pass
else
echo "Choose a profile to run from the list below:"
find Ansible/ -maxdepth 1 -name "*.yml" -type f -printf " - %f\n"
fi
}
_ansible

View file

@ -0,0 +1,3 @@
ansible
molecule
docker-py

View file

@ -0,0 +1,2 @@
ansible
python-dnf