Skip to content

Commit ee36bef

Browse files
Add ansible automation scripts and tasks
1 parent b093dac commit ee36bef

14 files changed

+266
-4
lines changed

Diff for: README.md

+19
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,22 @@ Ansible automation scripts for setting up a new mac machine
44
## TODO
55

66
- [] VM for testing automation changes
7+
8+
## Approach
9+
10+
- scripts/install.sh
11+
- install brew as a LOT depends on its existence
12+
- install ansible via brew
13+
- install git
14+
- install ohmyzsh if not exist (this check will handled by ansible)
15+
- nuke the zshrc so the one pulled in by yadm can be usedk
16+
- install yadm via brew
17+
- yadm clone your dotfiles repo
18+
- Replace the .zshrc created/modified by ohmyzsh installation with the one in dotfiles
19+
- Best way is to replace, need to see shell commands for that (maybe rm zshrc before yadm clone?
20+
- install powerlevel10k from scripts/install.sh
21+
- configure this manually
22+
- install zsh-autosuggestions
23+
- install rust
24+
- Install homebrew packages
25+
- Install homevrew cask packages

Diff for: ansible.cfg

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[defaults]
2+
nocows = True # no ascii art from cowsay
3+
roles_path = ./roles:/etc/ansible/roles
4+
inventory = inventory
5+
become = true # become the user, ansible becomes you or anyother user to run sudo commands
6+
stdout_callback = yaml # pretty print to stdout

Diff for: config.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
3+
configure_dotfiles: true
4+
configure_terminal: true
5+
configure_osx: true
6+
osx_script: "~/scripts/osx.sh"
7+
configure_node_with_volta: true
8+
install_rust: true
9+
dotfiles_repo: https://github.com/SaiKrishnaMohan7/dotfiles.git
10+
dotfiles_repo_accept_hostkey: true
11+
12+
# run brew upgrade every time before this is run
13+
homebrew_installed_packages:
14+
- ansible
15+
- git
16+
- go
17+
- nmap
18+
- volta
19+
- ssh-copy-id
20+
- neofetch
21+
- jq
22+
- tldr
23+
- tree
24+
- htop
25+
- tail
26+
- kubectl
27+
- helm
28+
- minikube
29+
- terraform
30+
- azure-cli
31+
- awscli
32+
- wireshark
33+
- yarn
34+
- yadm # dotfile management
35+
36+
homebrew_cask_appdir: /Applications
37+
homebrew_cask_apps:
38+
- google-chrome
39+
- docker
40+
- firefox
41+
- slack
42+
- obsidian
43+
- zoom
44+
# - discord only on personal mac
45+
- amethyst # tiling management
46+
- caffiene
47+
- 1password
48+
- 1password-cli
49+
- postman
50+
- postico # GUI for postgres
51+
- drawio
52+
- vagrant # Type 2 virtualization
53+
- virtualbox # Type 2 virtualization
54+
- visual-studio-code
55+
- iterm2

Diff for: install.sh

-4
This file was deleted.

Diff for: inventory

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[all]
2+
127.0.0.1 ansible_connection=local

Diff for: playbook.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
- hosts: localhost
2+
connection: local
3+
become: true
4+
5+
tasks:
6+
- debug:
7+
msg: Check we are running in the directory of the script
8+
failed_when: not ansible_env.PWD.endswith('/ansible_automation')
9+
10+
# Plays
11+
- name: Install Homebrew Packages
12+
import_tasks: tasks/install_brew_packages.yml
13+
14+
- name: Install Homebrew Cask Packages
15+
import_tasks: tasks/install_brew_cask_packages.yml
16+
17+
- name: Setup terminal app
18+
import_tasks: tasks/setup_terminal_app.yml
19+
when: configure_terminal
20+
21+
- name: Setup dotfiles
22+
import_tasks: tasks/setup_dotfiles.yml
23+
when: configure_dotfiles
24+
25+
- name: Configure osx
26+
import_tasks: tasks/configure_osx.yml
27+
when: configure_osx
28+
29+
- name: Setup rust
30+
import_tasks: tasks/install_rust.yml
31+
when: install_rust

Diff for: scripts/install.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/bash
2+
3+
# Check if brew is installed, if so don't do anything; Same for all the other installs in this file
4+
if ! command -v brew &> /dev/null
5+
then
6+
echo "brew is not installed, installing now..."
7+
# Install Homebrew
8+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
9+
exit
10+
fi
11+
12+
if ! command -v ansible &> /dev/null
13+
then
14+
echo "ansible is not installed, installing now..."
15+
# Install Homebrew
16+
brew install ansible
17+
exit
18+
fi

Diff for: tasks/install_brew_cask_packages.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
3+
- name: Install brew cask packages
4+
community.general.homebrew_cask:
5+
update_homebrew: true
6+
name: "{{ item.name | default(item) }}"
7+
state: "{{ item.state | default('present') }}"
8+
version: "{{ item.version | default(omit) }}"
9+
install_options: "{{ item.install_options | default('appdir=' + homebrew_cask_appdir) }}"
10+
global: true
11+
loop: "{{ homebrew_cask_apps }}"

Diff for: tasks/install_brew_packages.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
3+
- debug:
4+
msg: "Installing Homebrew Packages"
5+
6+
- name: Install homebrew packages
7+
community.general.homebrew:
8+
update_homebrew: true
9+
name: "{{ item.name | default(item) }}"
10+
state: "{{ item.state | default('present') }}"
11+
version: "{{ item.version | default(omit) }}"
12+
global: true
13+
loop: "{{ homebrew_installed_packages }}"
14+
tags:
15+
- brew
16+
17+
- name: homebrew cleanup
18+
command: brew cleanup

Diff for: tasks/install_rust.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
3+
- name: Install rust
4+
ansible.builtin.shell:
5+
cmd: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Diff for: tasks/osx_defaults.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
3+
- name: Run .osx dotfiles.
4+
ansible.builtin.shell:
5+
cmd: sh "{{ osx_script }}"

Diff for: tasks/setup_dotfiles.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
3+
# Clean up .zshrc before yadm pulls it in
4+
- name: Clean up .zshrc pre yadm
5+
ansible.builtin.shell:
6+
cmd: rm ~/.zshrc
7+
8+
# NOTE: This will be a url based clone; later update the git remote manually to ssh
9+
# Clone dotfiles repo with yadm
10+
- name: Clone dotfiles repo
11+
ansible.builtin.shell:
12+
cmd: yadm clone "{{ dotfiles_repo }}"

Diff for: tasks/setup_terminal_app.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
3+
# Clean Oh My ZSH directory
4+
- name: Clean up pre ohmyzsh install
5+
ansible.builtin.shell:
6+
cmd: rm -rf ~/.oh-my-zsh
7+
8+
# Install Oh My ZSH Directory
9+
- name: Install Oh My ZSH
10+
ansible.builtin.shell:
11+
cmd: sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
12+
13+
# Install plugins
14+
- name: Install zsh-autosuggestions
15+
ansible.builtin.shell:
16+
cmd: git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
17+
18+
- name: Install powerlevl10k
19+
ansible.builtin.shell:
20+
cmd: git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
21+

Diff for: unused-maybe-of-use-someday.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
homebrew_taps:
3+
- homebrew/core
4+
- homebrew/cask
5+
# NOTE: Since I am using yadm to manage my dotfiles, I do not need to clone the repo to my drive
6+
# dotfiles_repo_local_destination: ~/Projects/Personal/dotfiles
7+
# dotfiles_files:
8+
# - .zshrc
9+
# - .gitignore
10+
# - .inputrc
11+
# - .osx
12+
# - .vimrc
13+
14+
# Set to 'true' to configure the Dock via dockutil.
15+
# configure_dock: false
16+
# dockitems_remove: []
17+
# - Launchpad
18+
# - TV
19+
# - Podcasts
20+
# - 'App Store'
21+
# dockitems_persist: []
22+
# - name: "Sublime Text"
23+
# path: "/Applications/Sublime Text.app/"
24+
# pos: 5
25+
26+
# configure_sudoers: false
27+
# sudoers_custom_config: ''
28+
# Example:
29+
# sudoers_custom_config: |
30+
# # Allow users in admin group to use sudo with no password.
31+
# %admin ALL=(ALL) NOPASSWD: ALL
32+
33+
# See `geerlingguy.mas` role documentation for usage instructions.
34+
mas_installed_apps: []
35+
mas_email: ""
36+
mas_password: ""
37+
38+
osx_script: "~/scripts/.osx --no-restart"
39+
40+
# Install packages from other package managers.
41+
# Note: You are responsible for making sure the required package managers are
42+
# installed, eg. through homebrew.
43+
composer_packages: []
44+
# - name: drush
45+
# state: present # present/absent, default: present
46+
# version: "^8.1" # default: N/A
47+
gem_packages: []
48+
# - name: bundler
49+
# state: present # present/absent/latest, default: present
50+
# version: "~> 1.15.1" # default: N/A
51+
npm_packages: []
52+
# - name: webpack
53+
# state: present # present/absent/latest, default: present
54+
# version: "^2.6" # default: N/A
55+
56+
# pip_packages: []
57+
# - name: mkdocs
58+
# state: present # present/absent/latest, default: present
59+
# version: "0.16.3" # default: N/A
60+
61+
62+
# Glob pattern to ansible task files to run after all other tasks are finished.
63+
# post_provision_tasks: []

0 commit comments

Comments
 (0)