Add README for ansible/roles/core
+ Add blockchain subdirectory to root README + Ignore `node-modules` directory for future npm projects
This commit is contained in:
parent
8177d4c191
commit
cd63a02470
|
@ -9,3 +9,4 @@
|
|||
**/CMakeFiles/**
|
||||
**/Makefile
|
||||
**/*.cbp
|
||||
**/node-modules/
|
||||
|
|
|
@ -5,6 +5,7 @@ This repository is a collection of useful code snippets and configurations.
|
|||
```
|
||||
github.com/shaunrd0/klips/
|
||||
├── ansible # Ansible roles, playbooks, and examples
|
||||
├── blockchain # Blockchain related project templates and examples
|
||||
├── cpp # C++ programs, datastructures, and other examples
|
||||
├── figlet # Figlet fonts I like :)
|
||||
├── README.md
|
||||
|
|
|
@ -1,31 +1,112 @@
|
|||
Role Name
|
||||
Core
|
||||
=========
|
||||
|
||||
A brief description of the role goes here.
|
||||
An ansible role for deploying a default configuration for Ubuntu servers
|
||||
|
||||
This role installs ranger, vim with Pathogen and plugins, configures git, `.bashrc`, `.bash_aliases`,
|
||||
unattended-upgrades, SSH configurations, PAM modules, Yubikey authentication,
|
||||
and installs a custom MOTD to display on login.
|
||||
|
||||
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.
|
||||
None, this role will apply settings specified in `core/defaults/main.yml`
|
||||
The only requirement is that we can run this play on the remote host to configure.
|
||||
I test this role on Ubuntu servers.
|
||||
Though the way packages are installed in this role is not specific to Ubuntu,
|
||||
locations of certain destinations for configs may be slightly different.
|
||||
|
||||
**WARNING:**
|
||||
As this role is a WIP, there is a *temporary* requirement to modify
|
||||
`core/files/authorized_yubikeys` manually. Be sure these key prefixes match that
|
||||
of your yubikeys, and that the username also corresponds with the user on the
|
||||
system who should be identified and authenticated by this yubikey.
|
||||
|
||||
Example:
|
||||
```
|
||||
username:cccckey1cccc:cccckey2cccc
|
||||
```
|
||||
|
||||
Where the user `username` can be identified by *two* yubikeys.
|
||||
Both yubikeys generate OTP with a static prefix of
|
||||
`cccckey1cccc` or `cccckey2cccc`
|
||||
|
||||
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.
|
||||
`packages: [python-apt, git, vim, ssh, libpam-yubico, ranger]`
|
||||
* A list of packages to install on the system with the default package manager
|
||||
|
||||
`authusers: [user1, user2]`
|
||||
* The users that should bypass additional PAM authentication modules.
|
||||
This does not include public key authentication.
|
||||
All users must provide a valid key. This will only bypass passwords and 2FA
|
||||
|
||||
`ssh_port: 22`
|
||||
* The port SSH is running on the server
|
||||
|
||||
`auth_methods: "publickey,keyboard-interactive"`
|
||||
* Authentication methods to configure within `/etc/sshd_config` file
|
||||
|
||||
`git_email: "someemail@gmail.com"`
|
||||
`git_name: "Shaun Reed"`
|
||||
* The email address and name to configure within `~/.gitconfig` file.
|
||||
This applies to the user that executes ansible plays on the remote server.
|
||||
|
||||
```yml
|
||||
vim_plugins: [{ repo: 'dense-analysis/ale', dest: 'ale'},
|
||||
{ repo: 'chrisbra/Colorizer', dest: 'colorizer'},
|
||||
{ repo: 'ervandew/supertab', dest: 'supertab'},
|
||||
{ repo: 'chrisbra/unicode.vim', dest: 'unicode'},
|
||||
{ repo: 'vim-airline/vim-airline', dest: 'vim-airline'},
|
||||
{ repo: 'vim-airline/vim-airline-themes', dest: 'vim-airline-themes'},
|
||||
{ repo: 'mhinz/vim-signify', dest: 'signify'}
|
||||
]
|
||||
```
|
||||
* A list of vim plugins to install.
|
||||
These plugins will be installed for the user that executes ansible plays
|
||||
on the remote host. These will also be cloned into `/etc/skel/.vim/bundle/`,
|
||||
making all of these plugins available for all future users created on the system.
|
||||
Vim plugins are managed by Pathogen.
|
||||
|
||||
`upgrades_email: someemail@gmail.com`
|
||||
* Used to configure `/etc/apt/apt.conf.d/50unattended-upgrades`.
|
||||
Email alerts will be sent to this address when automatic upgrades are performed
|
||||
|
||||
|
||||
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.
|
||||
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:
|
||||
First, make sure all settings within `defaults/main.yml` are correct for your
|
||||
server. All settings and their purposes are outline in the section above.
|
||||
|
||||
- hosts: servers
|
||||
roles:
|
||||
- { role: username.rolename, x: 42 }
|
||||
Create a new ansible play. You can name it whatever you want, but this
|
||||
example play will simply be named `core.yml`.
|
||||
|
||||
```yml
|
||||
---
|
||||
- hosts: testserver
|
||||
become: yes
|
||||
roles:
|
||||
- core
|
||||
```
|
||||
|
||||
Make sure the IP for `testserver` is correct in the `/etc/ansible/hosts` file -
|
||||
```
|
||||
[testserver]
|
||||
123.123.123.123:22
|
||||
```
|
||||
|
||||
Run the play!
|
||||
|
||||
```bash
|
||||
ansible-playbook core.yml
|
||||
```
|
||||
|
||||
License
|
||||
-------
|
||||
|
@ -35,4 +116,9 @@ BSD
|
|||
Author Information
|
||||
------------------
|
||||
|
||||
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
||||
Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0
|
||||
|
||||
|
||||
TODO: Add variables for `authorized_yubikeys`
|
||||
TODO: Add variables for configuring a custom `/etc/hosts`
|
||||
TODO: Use a package manager, or official repository to install ranger
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ##
|
||||
## A custom bash script to configure vim with my preferred settings ##
|
||||
## Run as user with sudo within directory to store / stash .vimrc configs ##
|
||||
###############################################################################
|
||||
|
||||
|
||||
printf "\nUpdating, upgrading required packages...\n"
|
||||
sudo apt -y update && sudo apt -y upgrade
|
||||
sudo apt install vim git
|
||||
|
||||
# Clone klips repository in a temp directory
|
||||
git clone https://github.com/shaunrd0/klips temp/
|
||||
# Relocate the files we need and remove the temp directory
|
||||
mkdir -pv /etc/config-vim
|
||||
mv -fuv temp/README.md /etc/config-vim/ && mv -fuv temp/configs/.vimrc* /etc/config-vim/
|
||||
rm -Rf temp/
|
||||
printf "\n${GREEN}Klips config files updated"\
|
||||
"\nSee /etc/config-vim/README.md for more information.${NORMAL}\n\n"
|
||||
|
||||
# Create backup dir for .vimrc
|
||||
mkdir -pv /etc/config-vim/backup/
|
||||
printf "\n${GREEN}Backup directory created - /etc/config-vim/backup/${NORMAL}\n"
|
||||
|
||||
# Copy cloned clonfig into user directory
|
||||
cp /etc/config-vim/.vimrc ~/
|
||||
|
||||
# Copy our cloned config into global directories
|
||||
cp /etc/config-vim/.vimrc /etc/skel/.vimrc
|
||||
cp /etc/config-vim/.vimrc /etc/vim/vimrc
|
||||
printf "${GREEN}New /usr/share/vim/vimfiles configuration installed.${NORMAL}\n"
|
||||
|
||||
# Reinstall Pathogen plugin manager for vim
|
||||
# https://github.com/tpope/vim-pathogen
|
||||
printf "\n${RED}Removing any previous installations of Pathogen...${NORMAL}\n"
|
||||
sudo rm -f /usr/share/vim/vimfiles/autoload/pathogen.vim
|
||||
|
||||
# Install Pathogen
|
||||
printf "\n${GREEN}Installing Pathogen plugin manager for Vim....\n"\
|
||||
"\nIf they don't exist, we will create the following directories:\n"\
|
||||
"/usr/share/vim/vimfiles/autoload/ /usr/share/vim/vimfiles/bundle/${NORMAL}"
|
||||
mkdir -pv /usr/share/vim/vimfiles/autoload /usr/share/vim/vimfiles/bundle && \
|
||||
sudo curl -LSso /usr/share/vim/vimfiles/autoload/pathogen.vim https://tpo.pe/pathogen.vim
|
||||
printf "\n${GREEN}Pathogen has been installed! Plugins plugins can now be easily installed.\n"\
|
||||
"Clone any plugin repositories into /usr/share/vim/vimfiles/bundles${NORMAL}\n"
|
||||
|
||||
# Remove any plugins managed by this config tool (Klips)
|
||||
printf "\n${RED}Removing plugins installed by this tool...${NORMAL}\n"
|
||||
sudo rm -R /usr/share/vim/vimfiles/bundle/*
|
||||
|
||||
# Clone plugin repos into pathogen plugin directory
|
||||
printf "\n${GREEN}Installing updated plugins...${NORMAL}\n"
|
||||
git clone https://github.com/ervandew/supertab /usr/share/vim/vimfiles/bundle/supertab && \
|
||||
printf "\n${GREEN}Supertab plugin has been installed${NORMAL}\n\n" && \
|
||||
git clone https://github.com/xavierd/clang_complete /usr/share/vim/vimfiles/bundle/clang_complete && \
|
||||
printf "\n${GREEN}Clang Completion plugin has been installed${NORMAL}\n\n"
|
||||
vimConf=( "\n${UNDERLINE}Vim has been configured with the Klips repository.${NORMAL}" \
|
||||
"\nConfiguration Changes: " )
|
||||
printf '%b\n' "${vimConf[@]}"
|
||||
sudo cat /etc/klips/configs/.vimrc-README
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
- /etc/skel/.vim/bundle/
|
||||
- /etc/skel/.vim/autoload/
|
||||
|
||||
- name: Install Pathogen, sourcerer theme
|
||||
- name: Install Pathogen, sourcerer theme for ansible user
|
||||
copy:
|
||||
src: files/{{ item.src }}
|
||||
dest: /home/ansibleuser/.vim/{{ item.dest }}
|
||||
|
@ -25,12 +25,7 @@
|
|||
- { src: 'pathogen.vim', dest: 'autoload/pathogen.vim'}
|
||||
- { src: 'sourcerer.vim', dest: 'colors/sourcerer.vim'}
|
||||
|
||||
- name: Install sourcerer theme
|
||||
copy:
|
||||
src: files/pathogen.vim
|
||||
dest: /home/ansibleuser/.vim/autoload/
|
||||
|
||||
- name : Install vim plugins
|
||||
- name : Install vim plugins for ansible user
|
||||
git:
|
||||
repo: https://github.com/{{ item.repo }}
|
||||
dest: /home/ansibleuser/.vim/bundle/{{ item.dest }}
|
||||
|
@ -50,7 +45,7 @@
|
|||
dest: /etc/skel/.vim/bundle/{{ item.dest }}
|
||||
with_items: "{{ vim_plugins }}"
|
||||
|
||||
- name: Configure vim
|
||||
- name: Configure .vimrc for ansible user and skeleton files
|
||||
template:
|
||||
src: files/.vimrc
|
||||
dest: "{{ item }}"
|
||||
|
|
Loading…
Reference in New Issue