Files
dotfiles/ansible/roles/cheat/tasks/main.yml
Christopher Beckmann 48c80e05c1 fixed cheat role
2024-04-08 16:53:45 +02:00

71 lines
2.2 KiB
YAML

- name: check go version
command: go version
register: result
changed_when: no
ignore_errors: true
- name: Install glow
# become: true
command: go install github.com/charmbracelet/glow@latest
environment:
GOPATH: "{{ go_path }}"
register: glow
changed_when: glow.stdout is not match("") or glow.stderr is not match("")
failed_when: glow.rc > 0
when: result is succeeded
- debug: var=glow verbosity=2
- name: Install cheat
# become: true
shell: go install github.com/cheat/cheat/cmd/cheat@latest
environment:
GOPATH: "{{ go_path }}"
register: cheat
changed_when: cheat.rc == 0
changed_when: cheat.stdout is not match("") or cheat.stderr is not match("")
failed_when: cheat.rc > 0
when: result is succeeded
- debug: var=cheat verbosity=2
- name: Create required folders
file:
state: directory
dest: "{{ lookup('env', 'XDG_CONFIG_HOME') }}/{{ item.path }}"
with_filetree: ../templates
when: item.state == 'directory'
- name: Install glow config files
template:
src: "{{ item.src }}"
dest: "{{ lookup('env', 'XDG_CONFIG_HOME') }}/glow/{{ item.path }}"
owner: "{{ ansible_user_uid }}"
group: "{{ ansible_user_gid }}"
mode: '{{ item.mode }}'
with_filetree: templates/glow/
- name: Install cheat config files
template:
src: "{{ item.src }}"
dest: "{{ lookup('env', 'XDG_CONFIG_HOME') }}/cheat/{{ item.path }}"
owner: "{{ ansible_user_uid }}"
group: "{{ ansible_user_gid }}"
mode: '{{ item.mode }}'
with_filetree: templates/cheat/
- name: Add to .zshrc
lineinfile:
path: "{{ ansible_user_dir }}/.zshrc"
insertafter: '\[ -f {{ lookup("env", "XDG_CONFIG_HOME") }}.* \] && source {{ lookup("env", "XDG_CONFIG_HOME") }}.*'
regexp: '\[ -f {{ lookup("env", "XDG_CONFIG_HOME") }}/cheat/cheat\.zsh \] && source {{ lookup("env", "XDG_CONFIG_HOME") }}/cheat/cheat\.zsh'
line: '[ -f {{ lookup("env", "XDG_CONFIG_HOME") }}/cheat/cheat.zsh ] && source {{ lookup("env", "XDG_CONFIG_HOME") }}/cheat/cheat.zsh'
- name: Download Cheatsheets
git:
accept_newhostkey: true
repo: 'git@git.cbeck.tech:kamu/cheatsheets.git'
dest: "{{ lookup('env', 'XDG_CONFIG_HOME') }}/cheat/cheatsheets"
environment:
GIT_GERMINAL_PROMPT: 0