Use blocks to cut down on repeat code in user role

This commit is contained in:
Salt 2020-02-06 00:35:06 -06:00
parent 6eacfb3ba4
commit 60acdbc9cb

View File

@ -38,18 +38,18 @@
- name: Check for dotfile initialization - name: Check for dotfile initialization
stat: path=$HOME/.dotfiles stat: path=$HOME/.dotfiles
register: p register: p
- name: Initialize dotfiles
block:
- name: Configure git SSH substitute for GitHub - name: Configure git SSH substitute for GitHub
git_config: git_config:
name: url."https://github.com/".insteadOf name: url."https://github.com/".insteadOf
value: "git@github.com:" value: "git@github.com:"
scope: global scope: global
when: not p.stat.exists
- name: Configure git SSH substitute for GitLab - name: Configure git SSH substitute for GitLab
git_config: git_config:
name: url."https://gitlab.com/".insteadOf name: url."https://gitlab.com/".insteadOf
value: "git@gitlab.com:" value: "git@gitlab.com:"
scope: global scope: global
when: not p.stat.exists
- name: Clone bootstrap script - name: Clone bootstrap script
git: git:
accept_hostkey: yes accept_hostkey: yes
@ -57,17 +57,14 @@
dest: $HOME/bootstrap dest: $HOME/bootstrap
depth: 1 depth: 1
force: yes force: yes
when: not p.stat.exists
- name: Execute bootstrap script - name: Execute bootstrap script
shell: cd && ~/bootstrap/build-home.sh shell: cd && ~/bootstrap/build-home.sh
when: not p.stat.exists
- name: Disable untracked files on dotfiles - name: Disable untracked files on dotfiles
git_config: git_config:
name: status.showUntrackedFiles name: status.showUntrackedFiles
value: "no" value: "no"
scope: local scope: local
repo: ~/.dotfiles repo: ~/.dotfiles
when: not p.stat.exists
- name: Remove bootstrap script directory - name: Remove bootstrap script directory
file: file:
path: ~/bootstrap path: ~/bootstrap