More README updates to read(?)

This commit is contained in:
Shaun Reed 2019-08-31 02:47:50 -04:00
parent 8619d41265
commit 2bebf584f8
11 changed files with 208 additions and 74 deletions

View File

@ -1,7 +1,6 @@
# klips
Snippets that I frequently use and share
This repository is a collection of code snippets that I reuse, clone, or frequently refer to in regards to configurations or settings. This can be cloned as a whole and refered to locally as needed, or copied around and used to lay out templates for larger projects.
This repository is a collection of code snippets that I reuse, clone, or frequently refer to. This can be cloned as a whole or just viewed / copied as needed, used to lay out templates / automate tasks for larger projects.
The snippets are organized within topic-labeled folders. 'plates' is short-hand for templates, and houses all folders / projects that can be copied and edited / adjusted locally as templates for larger projects.
@ -16,10 +15,18 @@ https://github.com/shaunrd0/...
klips/
├── ansible
│   ├── apt-up.yml
│   ├── core.yml
│   ├── docker.yml
│   ├── hosts
│   ├── make-host.yml
│   ├── nginx.yml
│   └── roles
│   ├── core
│   ├── docker
│   └── nginx
├── configs
│   ├── .vimrc
│   └── .vimrc-README
├── plates
│   ├── cpp-cmake
│   └── cpp-launcher
@ -27,17 +34,27 @@ klips/
├── refs
│   └── doxygenROT
└── scripts
├── adduser.sh
├── cmake-build.sh
├── README.md
└── setup-vim.sh
```
ansible - Ansible roles, playbooks
- nginx.yml - Playbook example for using nginx role
- hosts - Same ansible hosts file
- apt-up.yml - Playbook to update servers / groups ad hoc
- roles - Basic ansible role created with ansible-galaxy command
-- nginx
- core.yml - Playbook example for using core configuration role
- docker.yml - Playbook example for using docker install role (Debian / Ubuntu)
- hosts - Same ansible hosts file
- make-host.yml - Playbook example for using multiple roles together to create a new host
- nginx.yml - Playbook example for using nginx role
- roles - Some simple Ansible roles created with `ansible-galaxy init <role> --offline` command
-- core - Role to configure a new host with basic authentication / package settings
-- docker - Role to install docker, docker-compose, configure docker user group (Debian / Ubuntu)
-- nginx - Role to install and configure a new nginx webserver on a host
configs
- .vimrc - Various settings for vim, can be copied or used with setup-vim.sh)
- .vimrc-README - What these settings do, output when setup-vim.sh is ran.)
plates
- cpp-cmake - Simple cpp executable template, built using cmake
@ -47,11 +64,22 @@ refs
- doxygenROT - Basic rule-of-thumb for Doxygen commenting
scripts
- adduser.sh - Script to add new user, run with sudo if you want to configure / allow user to sudo
-- ./adduser - (Print help text)
-- ./adduser <name> <userID> - (Don't need sudo if new user doesn't need it)
-- sudo ./adduser <name> <userID>
-- sudo ./adduser jeff 1005 - (Create jeff user and assign userID to 1005)
-- Follow prompts to configure password / sudo depending on needs of new user
- cmake-build.sh - Script to toss around and build cmake projects
- README.md - Further clarification of scripts
- setup-vim.sh - Script for setting up vim configuration
-- Includes Pathogen Plugin manager
-- Includes auto-completion (Clang_completion)
-- Supertab completion interaction (Tab to interact with completion context)
-- Syntax highlighting
-- Tabsize 2, use spaces in place of tabs
-- auto indentation, mouse interaction when supported
-- Custom keybind (Ctrl-e for jumping windows || Ctrl-w still works if not in a tabbed terminal where the same will close the tab)
-- See klips/configs/.vimrc-README for more information
configs
- .vimrc - Various settings for vim, can be copied or used with setup-vim.sh)
- .vimrc-README - What these settings do, output when setup-vim.sh is ran.)

18
ansible/README.md Normal file
View File

@ -0,0 +1,18 @@
# Ansible
A few simple roles / plays I've been able to piece together in learning how to use Ansible.
Playbooks
- apt-up.yml - Playbook to update servers / groups ad hoc
- core.yml - Playbook example for using core configuration role
- docker.yml - Playbook example for using docker install role (Debian / Ubuntu)
- hosts - Same ansible hosts file
- make-host.yml - Playbook example for using multiple roles together to create a new host
- nginx.yml - Playbook example for using nginx role
Roles
- roles - Basic ansible role created with ansible-galaxy command
-- core - Role to configure a new host with basic authentication / package settings
-- docker - Role to install docker, docker-compose, configure docker user group (Debian / Ubuntu)
-- nginx - Role to install and configure a new nginx webserver on a host

39
ansible/roles/README.md Normal file
View File

@ -0,0 +1,39 @@
# Roles
Some simple Ansible roles created with `ansible-galaxy init <role> --offline` command
klips/ansible/roles/...
-- core - Role to configure a new host with basic authentication / package settings
-- docker - Role to install docker, docker-compose, configure docker user group
-- nginx - Role to install and configure a new nginx webserver on a host
All of these roles assume you are using the apt package manager, and running a Debian / Ubuntu system.
core
------------
A simple role for configuring a set of packages / settings on a new Ubuntu host using Ansible.
Packages Added / Configured
- Git
-- Configure / set user name and email
- SSH
-- MOTD (Template, replacable, displayed on login.)
-- PAM (Template, replacable, authusers file to bypass)
-- authusers (Add users to file to bypass PAM settings)
- Vim
-- Install Vim
-- Run https://github.com/shaunrd0/klips/scripts/setup-vim.sh
docker
------------
A simple role for installing Docker and Docker Compose on a new Ubuntu host using Ansible.
nginx
------------
A simple role for installing and configuring nginx on a new Ubuntu host using Ansible. Supports templates for index.html and custom nginx.conf

View File

@ -1,38 +1,73 @@
Role Name
core
=========
A brief description of the role goes here.
A simple role for configuring a set of packages / settings on a new Ubuntu host using Ansible.
Packages Added / Configured
- Git
-- Configure / set user name and email
- SSH
-- MOTD (Template, replacable, displayed on login.)
-- PAM (Template, replacable, authusers file to bypass)
-- authusers (Add users to file to bypass PAM settings)
- Vim
-- Install Vim
-- Run https://github.com/shaunrd0/klips/scripts/setup-vim.sh
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.
Expects that the host is using apt package manager, and running a Debian / Ubuntu system.
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.
Found in `.../roles/core/defaults/main.yml`
```
---
packages: [git, vim, ssh]
ssh_port: 22
auth_methods: "publickey,keyboard-interactive"
git_email: "user@domain.com"
git_name: "First Last"
hostname: "localhost"
domain_name: "www.localhost.com"
```
Dependencies
------------
Basic package installation variable -
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.
packages - A list of packages to install when running core configuration. Add package to this list and it will be installed on your new host. Further configuration will need to be done manually, unless the role is modified otherwise.
SSH Configuration Variables -
ssh_port - The port to configure SSH to listen on
auth_methods - Authentication methods to allow SSH base configuration to use. Otherwise, specify a match within the sshd_config
MOTD Configuration Variables -
hostname - The hostname of the box you are using, used in the MOTD for a host-specific greeting, so you know which host you are logged into when glancing between terminals.
domain_name - The domain name, if available, associated with this host.
Git Configuration Variables -
git_email - Email address to configure with Git
git_name - Full name to configure with Git (First Last || Shaun Reed)
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:
After configuring the appropriate variables in `.../defaults/main.yml`, create the following play.yml and run `ansible-playbook play.yml` after setting the correct hosts in your `/etc/ansible/hosts` file.
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
```
---
- hosts: core
become: yes
roles:
- core
```
License
-------
Feel free to rename play.yml, hosts group name, etc. Just be sure it reflects to your settings in the related files.
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

View File

@ -2,8 +2,8 @@
packages: [git, vim, ssh]
ssh_port: 22
auth_methods: "publickey,keyboard-interactive"
git_email: "user@domain.com"
git_name: "First Last"
hostname: "localhost"
domain_name: "www.localhost.com"
git_email: "user@domain.com"
git_name: "First Last"

View File

@ -1,38 +1,36 @@
Role Name
docker
=========
A brief description of the role goes here.
A simple role for installing Docker and Docker Compose on a new Ubuntu host using Ansible.
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.
Expects that the host is using apt package manager, and running a Debian / Ubuntu system.
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.
Found in `.../roles/docker/defaults/main.yml`
```
---
docker_users: [user1, user2]
```
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.
docker_users - A list of users to configure / add to the docker group
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:
After setting the users to configure with Docker in `.../defaults/main.yml`, create the following play.yml and run `ansible-playbook play.yml` after setting the correct hosts in your `/etc/ansible/hosts` file.
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
```
---
- hosts: docker-host
become: yes
roles:
- docker
```
License
-------
Feel free to rename play.yml, hosts group name, etc. Just be sure it reflects to your settings in the related files.
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

View File

@ -1,38 +1,45 @@
Role Name
nginx
=========
A brief description of the role goes here.
A simple role for installing and configuring nginx on a new Ubuntu host using Ansible. Supports templates for index.html and custom nginx.conf
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.
Expects that the host is using apt package manager, and running a Debian / Ubuntu system.
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.
Found in `.../roles/nginx/defaults/main.yml`
```
---
domain_name: "localhost"
nginx_root_dir: "/var/www/html/"
index_files: "index.html index.htm"
```
Dependencies
------------
NGINX Configuration Variables -
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.
domain_name - Domain name to be used in nginx.conf, default value is the same as nginx base package default setting (localhost)
nginx_root_dir - The directory to point the default nginx server to
index_files - The files / types to be checked for content in our root directory
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:
After configuring the approprate variables in `.../defaults/main.yml`, create the following play.yml and run `ansible-playbook play.yml` after setting the correct hosts in your `/etc/ansible/hosts` file.
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
```
---
- hosts: nginx-server
become: yes
roles:
- nginx
```
License
-------
Feel free to rename play.yml, hosts group name, etc. Just be sure it reflects to your settings in the related files.
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

View File

@ -1,6 +1,4 @@
---
# defaults file for /etc/ansible/roles/nginx
#
domain_name: "localhost"
nginx_root_dir: "/var/www/html/"
index_files: "index.html index.htm"

View File

@ -1,3 +0,0 @@
---
- name: Start and enable nginx service
service: name=nginx state=restarted enabled=yes

View File

@ -21,7 +21,6 @@ Plugin Settings:
cd /usr/lib/x86_64-unknown-linux
ln -s libclang.so.1 libclang.so
- Supertab vim plugin has been installed and .vimrc configured for its use.
- Allows the use of TAB to enable code-completion context menu
-- https://github.com/ervandew/supertab

View File

@ -4,6 +4,21 @@ I write these scripts for my own use, and you may need to tweak them slightly to
Never run a script you can't read or understand. Comments can be found in the scripts, usually explaining them block-by-block. Below is my personal use cases for the scripts, to provide further insight into how I use them and how they might be useful to you.
#### adduser.sh
This script was made on Ubuntu when creating a few users across multiple hosts. Syntax requires at least 2 arguments when running the script, otherwise help text will be output warning of correct usage and available options. The script can be used to configure sudo on a new user if the script itself is ran with sudo. Otherwise, creating a default user with or without a password is possible without sudo. If the script is ran on an existing user or a userID that is already in use is passed, no changes will happen in user-creation but you may still allow the user to sudo and change their password.
Syntax -
./adduser (Help text)
./adduser jeff 1005 (Create user jeff with userID 1005, can't configure sudo, prompt for possible password creation)
sudo ./adduser (Help text)
sudo ./adduser jeffy 1010 (Create user jeffy with userID 1010, can configure sudo, possible password creation)
Didn't configure sudo, and don't want to do so manually? Re-run the script on the existing user just as above, and accept the prompt for sudo configuration.
sudo ./adduser jeff 1005 (User creation will fail, follow prompts to configure sudo and / or reset user password)
#### cmake-build.sh
I usually run this script within whatever directory I'm working in, hence the infinite loop, I leave the script running until I'm done with my work and move to a new directory / cmake project.