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,40 +38,37 @@
- name: Check for dotfile initialization - name: Check for dotfile initialization
stat: path=$HOME/.dotfiles stat: path=$HOME/.dotfiles
register: p register: p
- name: Configure git SSH substitute for GitHub - name: Initialize dotfiles
git_config: block:
name: url."https://github.com/".insteadOf - name: Configure git SSH substitute for GitHub
value: "git@github.com:" git_config:
scope: global name: url."https://github.com/".insteadOf
when: not p.stat.exists value: "git@github.com:"
- name: Configure git SSH substitute for GitLab scope: global
git_config: - name: Configure git SSH substitute for GitLab
name: url."https://gitlab.com/".insteadOf git_config:
value: "git@gitlab.com:" name: url."https://gitlab.com/".insteadOf
scope: global value: "git@gitlab.com:"
when: not p.stat.exists scope: global
- name: Clone bootstrap script - name: Clone bootstrap script
git: git:
accept_hostkey: yes accept_hostkey: yes
repo: git@gitlab.com:rehashedsalt/bootstrap repo: git@gitlab.com:rehashedsalt/bootstrap
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 - name: Disable untracked files on dotfiles
when: not p.stat.exists git_config:
- name: Disable untracked files on dotfiles name: status.showUntrackedFiles
git_config: value: "no"
name: status.showUntrackedFiles scope: local
value: "no" repo: ~/.dotfiles
scope: local - name: Remove bootstrap script directory
repo: ~/.dotfiles file:
when: not p.stat.exists path: ~/bootstrap
- name: Remove bootstrap script directory state: absent
file:
path: ~/bootstrap
state: absent
when: not p.stat.exists when: not p.stat.exists
become: yes become: yes
become_user: salt become_user: salt