From c0360147ef86cb79c37be2d3e10f285d1a5ba2e0 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Sun, 24 Oct 2021 22:48:03 +0100 Subject: [PATCH] Start using Ansible for config management --- .conduit.yaml | 46 +----------------------------- README.md | 12 ++++---- main.yaml | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 52 deletions(-) create mode 100644 main.yaml diff --git a/.conduit.yaml b/.conduit.yaml index d39b755..d6b7391 100644 --- a/.conduit.yaml +++ b/.conduit.yaml @@ -1,47 +1,3 @@ --- - location: ~/.config/zsh -- apt: - - zsh - - zsh-doc - - pinentry-curses -- brew: - - zsh -- pacman: - - zsh -- dnf: - - util-linux-user - - zsh -- command: - - install: sudo chsh -s `which zsh` $USER - remove: sudo chsh -s `which bash` $USER -- symlink: - - {src: zlogin, dst: ~/.zlogin} - - {src: zlogout, dst: ~/.zlogout} - - {src: zprofile, dst: ~/.zprofile} - - {src: zshenv, dst: ~/.zshenv} - - {src: zshrc, dst: ~/.zshrc} - - src: prompt_fresh_setup - dst: ~/.local/share/zsh/site-functions/prompt_fresh_setup - - src: build/_build-dir - dst: ~/.local/share/zsh/site-functions/_build-dir - - src: sandbox/_sandbox - dst: ~/.local/share/zsh/site-functions/_sandbox - - src: layout/_layout - dst: ~/.local/share/zsh/site-functions/_layout - - src: notes/_note - dst: ~/.local/share/zsh/site-functions/_note -- repo: - - https://github.com/zsh-users/zsh-autosuggestions.git - - https://github.com/zsh-users/zsh-history-substring-search.git - - https://github.com/zsh-users/zsh-syntax-highlighting.git - - https://github.com/zsh-users/zsh-completions.git - - https://github.com/junegunn/fzf.git -- command: - - fzf/install --bin -- symlink: - - {src: fzf/bin/fzf, dst: ~/.local/bin/fzf} - - {src: fzf/bin/fzf-tmux, dst: ~/.local/bin/fzf-tmux} - - {src: cmake-uninstall, dst: ~/.local/bin/cmake-uninstall} -- command: - - zsh update-completion-links.zsh -- message: zsh will be the default prompt after next login +- command: ansible-playbook main.yaml --ask-become-pass diff --git a/README.md b/README.md index aa1cc25..116cdbc 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,13 @@ -## [conduit][conduit] +## Ansible -Simple, local, configuration manager. +To install this Zsh configuration: -Installation of the configuration files in this repository is orchestrated by -[conduit][conduit] as defined in the [`.conduit.yaml`](.conduit.yaml) file. This -includes [Zsh][zsh] package installs, setting [Zsh][zsh] as the users default -shell, and symbolic linking file such as [`zshrc`](zshrc) to `~/.zshrc`, and -cloning plugin repositories. The repository is cloned to `~/.config/zsh`. +```console +$ ansible-playbook main.yaml --ask-become-pass +``` ## Prompt diff --git a/main.yaml b/main.yaml new file mode 100644 index 0000000..815a40e --- /dev/null +++ b/main.yaml @@ -0,0 +1,79 @@ +# yaml-language-server: $schema=https://json.schemastore.org/ansible-playbook.json +--- +- hosts: localhost + tasks: + - name: Install Zsh packages + package: {name: zsh, state: present} + + - name: Install Zsh Debian packages + when: ansible_os_family == "Debian" + apt: {name: '{{item}}', state: present} + become: true + with_items: + - zsh-doc + - pinentry-curses + + - name: Clone Zsh Git Repositories + git: + repo: '{{item.repo}}' + dest: '{{item.dest}}' + with_items: + - repo: https://github.com/zsh-users/zsh-autosuggestions.git + dest: ~/.config/zsh/zsh-autosuggestions + - repo: https://github.com/zsh-users/zsh-history-substring-search.git + dest: ~/.config/zsh/zsh-history-substring-search + - repo: https://github.com/zsh-users/zsh-syntax-highlighting.git + dest: ~/.config/zsh/zsh-syntax-highlighting + - repo: https://github.com/zsh-users/zsh-completions.git + dest: ~/.config/zsh/zsh-completions + - repo: https://github.com/junegunn/fzf.git + dest: ~/.config/zsh/fzf + + - name: Install fzf + command: + cmd: ~/.config/zsh/fzf/install --bin + creates: ~/.config/zsh/fzf/bin/fzf + + - name: Create zsh symboic links + file: + state: link + src: '{{item.src}}' + dest: '{{item.dest}}' + with_items: + - src: ~/.config/zsh/zlogin + dest: ~/.zlogin + - src: ~/.config/zsh/zlogout + dest: ~/.zlogout + - src: ~/.config/zsh/zprofile + dest: ~/.zprofile + - src: ~/.config/zsh/zshenv + dest: ~/.zshenv + - src: ~/.config/zsh/zshrc + dest: ~/.zshrc + - src: ~/.config/zsh/prompt_fresh_setup + dest: ~/.local/share/zsh/site-functions/prompt_fresh_setup + - src: ~/.config/zsh/build/_build-dir + dest: ~/.local/share/zsh/site-functions/_build-dir + - src: ~/.config/zsh/sandbox/_sandbox + dest: ~/.local/share/zsh/site-functions/_sandbox + - src: ~/.config/zsh/layout/_layout + dest: ~/.local/share/zsh/site-functions/_layout + - src: ~/.config/zsh/notes/_note + dest: ~/.local/share/zsh/site-functions/_note + - src: ~/.config/zsh/fzf/bin/fzf + dest: ~/.local/bin/fzf + - src: ~/.config/zsh/fzf/bin/fzf-tmux + dest: ~/.local/bin/fzf-tmux + - src: ~/.config/zsh/cmake-uninstall + dest: ~/.local/bin/cmake-uninstall + + - name: Get absolute path to Zsh + shell: which zsh + register: zsh + changed_when: false + + - name: Set users default shell to Zsh + user: + name: benie + shell: '{{zsh.stdout}}' + become: true