Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lodotek committed Jun 2, 2022
0 parents commit ca5808d
Show file tree
Hide file tree
Showing 48 changed files with 2,557 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/all-in-one-linter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
#################################
#################################
## Super Linter GitHub Actions ##
#################################
#################################
name: Lint Code Base

#
# Documentation:
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions
#

#############################
# Start the job on all push #
#############################
on:
push:

###############
# Set the Job #
###############
jobs:
build:
# Name the Job
name: Lint Code Base
# Set the agent to run on
runs-on: ubuntu-latest

##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v3
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0

################################
# Run Linter against code base #
################################
- name: Lint Code Base
uses: github/super-linter/slim@v4
env:
VALIDATE_ALL_CODEBASmac-dev-playbook/tasks/packages.yml: false
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.retry
.DS_Store
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


.PHONY: super-linter
super-linter:
docker run -e RUN_LOCAL=true -v $$(pwd):/tmp/lint github/super-linter
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# MacOS Ansible Playbook

This an Ansible Playbook to provision and customize my development environment on OSX.

## What does this playbook provide ?

It will :
* create useful directories.
* install packages (brew taps, asdf, npm, etc).
* copy dotfiles which configure various applications (Git, npm, terraform, asdf) into your home dir.
* copy in some zsh scripts (configurations, helper functions, aliases, etc)

## Install Instructions

* checkout this repo to `~/src/macos-devenv-ansible-provisioner`.
* copy `roles/mac-dev-playbook/files/ansible/ansible.cfg` to `~/.ansible.cfg`
* Create file `inventory` @ `~/.ansible/inventory` e.g.

```text
[localhost]
yourMacHostName gpg_key=${your-local-gpg-key}
```
* then go to `~/src/macos-devenv-ansible-provisioner`.
* run `ansible-playbook main.yml --diff --verbose --inventory ~/.inventory --limit $(hostname)`.

## Manual configurations

* Configure iTerm2 <https://apple.stackexchange.com/questions/136928/using-alt-cmd-right-left-arrow-in-iterm>


## Can I use it ?

Use at your own risk, this playbook doesn't aim to be used by anyone else. Please be sure to backup your current ~/.zshrc.rc file before executing this play-book ( as it will be overwritten with one from this repo)

### asdf : install all plugins at once

```shell
cut -d ' ' -f1 .tool-versions | xargs -I _ asdf plugin-add _
```
5 changes: 5 additions & 0 deletions main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- hosts: localhost
connection: local
roles:
- mac-dev-playbook
82 changes: 82 additions & 0 deletions roles/mac-dev-playbook/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---

homebrew_taps:
- homebrew/core
- wagoodman/dive
- hashicorp/tap

homebrew_absent_packages:
- tfenv
# - kubernetes-cli
- conftest
- hub
- krew
- yq # use python-yq instead

homebrew_installed_packages:
# - ansible # Installed via Pip.
- adr-tools
- autojump
- antigen # package manager for zsh
- asdf # asdf is package manager
- bash
- bash-completion
- bat # cat with wings
- bats # Bats is a Batch Test Suite
- direnv # augments existing shells with a new feature that can load and unload environment variables depending on the current directory.
- k9s # k9s is a Kubernetes CLI
- dive # Tools to explore docker layers with an UI
- dos2unix # Convert files from DOS to Unix format
- fluxcd/tap/flux # Flux is a Kubernetes Helm chart manager
- git # Git is a version control system
- github/gh/gh # GitHub CLI
- go
- gnu-sed # GNU version of sed
- gnupg # gnupg is a tool for managing GnuPG keys
- graphviz # Graphviz is a graph visualization tool
- gpg-suite-no-mail # For signing commits
- hashicorp/tap/terraform-ls # terraform-ls is a terraform plugin for vscode
- hashicorp/tap/waypoint # waypoint
# There is a bug, install it manually
#- homebrew/cask-fonts/font-hack-nerd-font
- highlight # Syntax highlighting for your terminal
- npm
- node
- nvm # Node Version Manager
- openssl # OpenSSL is a toolkit for implementing SSL/TLS
- pigz # gzip with parallel support
- jq # jq is a lightweight and flexible command-line JSON processor
- tree # tree is a directory listing utility
- vault # Vault is a tool for managing secrets
- wget # wget is a command line downloader
- python-yq # python-yq
- zsh # zsh is a shell interpreter for interactive programs and scripts

homebrew_cask_apps:
# - firefox # Firefox is a web browser
- google-cloud-sdk # Google Cloud SDK is a command-line interface for Google Cloud Platform
- iterm2 # iTerm2 is a terminal replacement
- intellij-idea # IntelliJ IDEA is a Java IDE
- keystore-explorer # Keystore Explorer is a tool for managing Java keystores
- visual-studio-code # Visual Studio Code is a code editor
- vlc # VLC is a free and open source cross-platform multimedia player and framework

npm_installed_packages:
- tldr
- yarn
- meta

# FIXME Use directly .tool-versions
asdf_plugins:
- { name: terraform }
- { name: kubectl }
- { name: terraform-docs }
- { name: conftest }
- { name: terraform-validator }
- { name: fluxctl }
- { name: hub }

pip_packages:
# - aiven-client # https://aiven.io/
- cookiecutter
- howdoi
1 change: 1 addition & 0 deletions roles/mac-dev-playbook/files/.pyenv/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8.9
26 changes: 26 additions & 0 deletions roles/mac-dev-playbook/files/.zshrc.d/_oh-my-zsh-plugins.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env zsh

# Plugins are listed here https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins
plugins=(
asdf
autojump
colored-man-pages
colorize
common-aliases
cp
docker
docker-compose
fzf
gcloud
gh
git
helm
iterm2
kube-ps1
kubectl
last-working-dir
macos
terraform
web-search
zsh-interactive-cd
)
47 changes: 47 additions & 0 deletions roles/mac-dev-playbook/files/.zshrc.d/aliases.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env zsh

### FileSearch ###
function f() { find . -iname "*$1*" ${@:2} }
function r() { grep "$1" ${@:2} -R . }

### mkdir and cd ###
function mkcd() { mkdir -p "$@" && cd "$_"; }

function runans() {
ansible-playbook main.yml --diff --verbose --limit $(hostname)
}

alias cd..="cd .."
alias ..="cd .."

function cheat(){
echo "gitcheat"
echo "syscheat"
echo "syscheat"
echo "k8scheat"
echo "shellcheat"
echo "gitmess"
echo "good-readme"
}

alias gitcheat="cat ~/git-cheat-sheet.txt"
alias syscheat="cat ~/sys-cheat-sheet.txt"
alias osxcheat="cat ~/osx-cheat-sheet.txt"
alias k8scheat="cat ~/k8s-cheat-sheet.txt"
alias shellcheat="cat ~/shell-cheat-sheet.md"
alias gitmess="cat ~/.gitmessage"
alias zshshortcut="open http://www.geekmind.net/2011/01/shortcuts-to-improve-your-bash-zsh.html"
alias good-readme="open https://github.com/othneildrew/Best-README-Template"

# Makefile
alias m="make"

# Howdoi
alias hdi="howdoi -c -n 2"

# highlight
alias yaml="highlight --force --syntax yaml"

# Notify
alias notify='osascript -e "display notification \"Script finished\" with title \"Over\""'
alias n=notify
38 changes: 38 additions & 0 deletions roles/mac-dev-playbook/files/.zshrc.d/asdf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env zsh

# Had to add this to get asdf to work on my mac

source $(brew --prefix asdf)/libexec/asdf.sh

## some packages to install
# conftest
# flux2
# fluxctl
# helm
# hub
# kubectl
# shellcheck
# shfmt
# terraform
# terraform-docs
# terraform-validator

## Some functions to help
function _asdf_install_plugin() {
local ASDF_TOOLS_VERSIONS_FILENAME="$HOME/.tool-versions"
for plugin in $(awk '{print $1}' ${ASDF_TOOLS_VERSIONS_FILENAME}); do \
asdf plugin add $plugin || true; \
done
}

function asdf_install_version() {
_asdf_install_plugin
local ASDF_TOOLS_VERSIONS_FILENAME="$HOME/.tool-versions"
cat ${ASDF_TOOLS_VERSIONS_FILENAME} | while read -r plugin version; do \
asdf install ${plugin} ${version}; \
done
}

## Enable poetry

export PATH="$HOME/.asdf/installs/poetry/1.1.13/bin:$PATH"
5 changes: 5 additions & 0 deletions roles/mac-dev-playbook/files/.zshrc.d/autojump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env zsh

#alias j='autojump'

[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
4 changes: 4 additions & 0 deletions roles/mac-dev-playbook/files/.zshrc.d/coreutils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env zsh

# Add coreutils to PATH
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
3 changes: 3 additions & 0 deletions roles/mac-dev-playbook/files/.zshrc.d/direnv_init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env zsh

eval "$(direnv hook zsh)"
3 changes: 3 additions & 0 deletions roles/mac-dev-playbook/files/.zshrc.d/docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env zsh

export DOCKER_HOST="unix:///var/run/docker.sock"
6 changes: 6 additions & 0 deletions roles/mac-dev-playbook/files/.zshrc.d/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env zsh

#### Paths ###
export PATH="$PATH:/usr/local/share/python:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
export REPOS=$HOME/src

8 changes: 8 additions & 0 deletions roles/mac-dev-playbook/files/.zshrc.d/gcloud.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env zsh

alias gclo="gcloud"
alias gcloalu="gcloud auth login --update-adc"

# Autocompletion
source '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc'
source '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc'
8 changes: 8 additions & 0 deletions roles/mac-dev-playbook/files/.zshrc.d/git.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env zsh

alias browse="g config --get remote.origin.url | gsed -r -e 's/git@github\.com:(\w+)\/(.*)(:\.git)?/https:\/\/github.com\/\1\/\2/g' | xargs open"

alias gcml="gcm && gl"

### Editor ###
export EDITOR='code --wait'
3 changes: 3 additions & 0 deletions roles/mac-dev-playbook/files/.zshrc.d/github.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env zsh

eval "$(gh completion --shell zsh)"
3 changes: 3 additions & 0 deletions roles/mac-dev-playbook/files/.zshrc.d/gnupg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env zsh

export GUILE_TLS_CERTIFICATE_DIRECTORY=/usr/local/etc/gnutls/
10 changes: 10 additions & 0 deletions roles/mac-dev-playbook/files/.zshrc.d/golang.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env zsh

export PATH=$PATH:~/go/bin
export GOROOT=/usr/local/opt/go/libexec
export GOPATH=~/go/
export GO111MODULE=on

alias got="go test"
alias gotv="go test -cover"
alias golang="howdoi golang"
3 changes: 3 additions & 0 deletions roles/mac-dev-playbook/files/.zshrc.d/krew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env zsh

export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
6 changes: 6 additions & 0 deletions roles/mac-dev-playbook/files/.zshrc.d/kustomize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env zsh

alias kst="kustomize"
alias kstb="kst build"
alias kstc="kst create"
alias kste="kst edit"
5 changes: 5 additions & 0 deletions roles/mac-dev-playbook/files/.zshrc.d/meta.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env zsh

alias mgu="meta git update"
alias mgp="meta git pull"
alias mgup="gl && mgu && mgp"
3 changes: 3 additions & 0 deletions roles/mac-dev-playbook/files/.zshrc.d/npm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env zsh

export PATH="$HOME/.npm-packages/bin:$PATH"
Loading

0 comments on commit ca5808d

Please sign in to comment.