This commit is contained in:
Eryn Wells 2024-11-08 08:24:06 -08:00
parent 3b509c45d1
commit d6bb7ae726
11 changed files with 179 additions and 51 deletions

16
Ansible/ansible.cfg Normal file
View file

@ -0,0 +1,16 @@
[defaults]
bin_ansible_callbacks = True
callbacks_enabled = ansible.posix.profile_tasks, ansible.posix.timer
remote_user = eryn
roles_path = roles
stdout_callback = community.general.yaml
[connection]
pipelining = true
[ssh_connection]
ssh_args = -o ControlMaster=auto -o ControlPersist=60s
[vault]
username = ansible-infrastructure-vault
keyname = default

View file

@ -0,0 +1,4 @@
---
- name: Rediscover package manager
ansible.builtin.setup:
gather_subset: pkg_mgr

View file

@ -0,0 +1,3 @@
---
- name: (macOS) Configure homebrew
ansible.builtin.include_tasks: homebrew.yml

View file

@ -0,0 +1,37 @@
---
- name: (macOS | homebrew) Does the brew command exist?
ansible.builtin.stat:
path: /opt/homebrew/bin/brew
register: _dotfiles_homebrew_brew
- name: (macOS | homebrew) Install Homebrew
when: not _dotfiles_homebrew_brew.stat.exists
block:
- name: (macOS | homebrew) Create temporary file for install script
ansible.builtin.tempfile:
state: file
prefix: homebrew-install
register: _dotfiles_homebrew_install_script
- name: (macOS | homebrew) Set up homebrew
block:
- name: (macOS | homebrew) Fetch install script
ansible.builtin.get_url:
url: https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
dest: "{{ _dotfiles_homebrew_install_script.path }}"
mode: "0644"
- name: (macOS | homebrew) Run install script
ansible.builtin.command:
cmd: bash {{ _dotfiles_homebrew_install_script.path }}
environment:
NONINTERACTIVE: 1
- name: (macOS | homebrew) Gather package manager facts
ansible.builtin.setup:
gather_subset: pkg_mgr
always:
- name: (macOS | homebrew) Remove temporary install script
ansible.builtin.file:
path: "{{ _dotfiles_homebrew_install_script.path }}"
state: absent

View file

@ -0,0 +1,28 @@
---
- name: (dotfiles) ZSH
ansible.builtin.include_tasks: zsh.yml
tags: [ always, dotfiles_shell, dotfiles_zsh ]
- name: (dotfiles) Vim
ansible.builtin.include_tasks: vim.yml
tags: [ always, dotfiles_vim ]
- name: (dotfiles) Emacs
ansible.builtin.include_tasks: emacs.yml
tags: dotfiles_emacs
- name: (dotfiles) Git
ansible.builtin.include_tasks: git.yml
tags: [ always, dotfiles_git ]
- name: (dotfiles) Mutt
ansible.builtin.include_tasks: mutt.yml
tags: dotfiles_mutt
- name: (dotfiles) Shell utilities
ansible.builtin.include_tasks: shell_utilities.yml
tags: dotfiles_shell
- name: (dotfiles) Nethack
ansible.builtin.include_tasks: nethack.yml
tags: dotfiles_nethack

View file

@ -1,26 +1,17 @@
---
- name: ZSH
ansible.builtin.include_tasks: zsh.yml
tags: dotfiles_zsh
- name: Bootstrap system
ansible.builtin.include_tasks: "{{ ansible_facts.os_family | lower }}/bootstrap.yml"
- name: Vim
ansible.builtin.include_tasks: vim.yml
tags: dotfiles_vim
#- name: Install packages
# ansible.builtin.include_tasks: packages.yml
- name: Emacs
ansible.builtin.include_tasks: emacs.yml
tags: dotfiles_emacs
- name: Git
ansible.builtin.include_tasks: git.yml
tags: dotfiles_git
- name: Mutt
ansible.builtin.include_tasks: mutt.yml
tags: dotfiles_mutt
- name: Shell utilities
ansible.builtin.include_tasks: shell_utilities.yml
- name: Nethack
ansible.builtin.include_tasks: nethack.yml
- name: Link dotfiles
ansible.builtin.include_tasks: dotfiles.yml
tags:
- dotfiles_git
- dotfiles_mutt
- dotfiles_neovim
- dotfiles_nethack
- dotfiles_shell
- dotfiles_vim
- dotfiles_zsh

View file

@ -1,4 +1,12 @@
---
- name: (nethack) Install nethack package
ansible.builtin.package:
name: nethack
state: present
when:
- dotfiles_install_packages is defined
- "'nethack' in dotfiles_install_packages"
- name: (nethack) Link nethackrc
ansible.builtin.file:
path: ~/.nethackrc

View file

@ -0,0 +1,13 @@
---
- name: Install packages
become: "{{ _dotfiles_requires_become[ansible_facts.pkg_mgr] | default(true) }}"
vars:
package_names: _dotfiles_package_names[ansible_facts.pkg_mgr]
ansible.builtin.package:
name: >
{{
package_names[package] | default(package)
for package
in (_dotfiles_core_packages + dotfiles_install_packages)
}}
state: present

View file

@ -7,11 +7,13 @@
force: true
- name: (neovim) Create standard config directory
tags: dotfiles_neovim
ansible.builtin.file:
path: ~/.config
state: directory
- name: (neovim) Link config
tags: dotfiles_neovim
ansible.builtin.file:
path: ~/.config/nvim
src: "{{ role_path }}/files/neovim"
@ -19,6 +21,7 @@
force: true
- name: (neovim) Create .local directories
tags: dotfiles_neovim
ansible.builtin.file:
path: "{{ item }}"
state: directory

View file

@ -1,31 +1,45 @@
---
- name: (zsh) Link startup files
ansible.builtin.file:
path: ~/.{{ item }}
src: "{{ role_path }}/files/zsh/{{ item }}"
state: link
force: true
loop:
- zshenv
- zshrc
- zprofile
- name: (zsh) Find zsh binary
ansible.builtin.command:
cmd: sh -c 'which zsh'
register: _dotfiles_which_zsh
- name: (zsh) Create zsh directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
force: true
loop:
- ~/.zsh
- ~/.zsh/cache
- name: (zsh) Configure zsh
when: (_dotfiles_which_zsh | length) > 0
block:
- name: (zsh) Make zsh my shell
ansible.builtin.user:
name: "{{ ansible_user }}"
shell: "{{ _dotfiles_which_zsh.stdout }}"
state: present
- name: (zsh) Link function library directories
ansible.builtin.file:
path: ~/.zsh/{{ item }}
src: "{{ role_path }}/files/zsh/{{ item }}"
state: link
force: true
loop:
- init-env-functions
- init-rc-functions
- functions
- name: (zsh) Link startup files
ansible.builtin.file:
path: ~/.{{ item }}
src: "{{ role_path }}/files/zsh/{{ item }}"
state: link
force: true
loop:
- zshenv
- zshrc
- zprofile
- name: (zsh) Create zsh directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
force: true
loop:
- ~/.zsh
- ~/.zsh/cache
- name: (zsh) Link function library directories
ansible.builtin.file:
path: ~/.zsh/{{ item }}
src: "{{ role_path }}/files/zsh/{{ item }}"
state: link
force: true
loop:
- init-env-functions
- init-rc-functions
- functions

View file

@ -0,0 +1,11 @@
_dotfiles_core_packages:
- zsh
- git
- tmux
- neovim
_dotfiles_package_names:
homebrew:
_dotfiles_requires_become:
homebrew: false