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
stat: path=$HOME/.dotfiles
register: p
- name: Configure git SSH substitute for GitHub
git_config:
name: url."https://github.com/".insteadOf
value: "git@github.com:"
scope: global
when: not p.stat.exists
- name: Configure git SSH substitute for GitLab
git_config:
name: url."https://gitlab.com/".insteadOf
value: "git@gitlab.com:"
scope: global
when: not p.stat.exists
- name: Clone bootstrap script
git:
accept_hostkey: yes
repo: git@gitlab.com:rehashedsalt/bootstrap
dest: $HOME/bootstrap
depth: 1
force: yes
when: not p.stat.exists
- name: Execute bootstrap script
shell: cd && ~/bootstrap/build-home.sh
when: not p.stat.exists
- name: Disable untracked files on dotfiles
git_config:
name: status.showUntrackedFiles
value: "no"
scope: local
repo: ~/.dotfiles
when: not p.stat.exists
- name: Remove bootstrap script directory
file:
path: ~/bootstrap
state: absent
- name: Initialize dotfiles
block:
- name: Configure git SSH substitute for GitHub
git_config:
name: url."https://github.com/".insteadOf
value: "git@github.com:"
scope: global
- name: Configure git SSH substitute for GitLab
git_config:
name: url."https://gitlab.com/".insteadOf
value: "git@gitlab.com:"
scope: global
- name: Clone bootstrap script
git:
accept_hostkey: yes
repo: git@gitlab.com:rehashedsalt/bootstrap
dest: $HOME/bootstrap
depth: 1
force: yes
- name: Execute bootstrap script
shell: cd && ~/bootstrap/build-home.sh
- name: Disable untracked files on dotfiles
git_config:
name: status.showUntrackedFiles
value: "no"
scope: local
repo: ~/.dotfiles
- name: Remove bootstrap script directory
file:
path: ~/bootstrap
state: absent
when: not p.stat.exists
become: yes
become_user: salt