Skip to content

Commit

Permalink
idempotent fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dgibbs64 committed Aug 30, 2024
1 parent 85df623 commit afa70cf
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
3 changes: 2 additions & 1 deletion tasks/gdu.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
- name: Get installed packages
- name: "Get installed packages"
ansible.builtin.package_facts:
manager: auto
when: ansible_facts.packages is not defined

- name: "Ensure ncdu is removed"
ansible.builtin.package:
Expand Down
14 changes: 10 additions & 4 deletions tasks/vim.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Get installed packages
- name: "Get installed packages"
ansible.builtin.package_facts:
manager: auto
when: ansible_facts.packages is not defined
Expand All @@ -16,7 +16,13 @@
state: directory
owner: "{{ ansible_user_id }}"
group: "{{ ansible_user_gid }}"
mode: '0755'
mode: "0755"
when: "'neovim' in ansible_facts.packages and disable_neovim_mouse_support"

- name: "Check if init.vim exists"
ansible.builtin.stat:
path: "{{ lookup('env', 'HOME') }}/.config/nvim/init.vim"
register: init_vim_stat
when: "'neovim' in ansible_facts.packages and disable_neovim_mouse_support"

- name: "Ensure init.vim exists"
Expand All @@ -25,8 +31,8 @@
state: touch
owner: "{{ ansible_user_id }}"
group: "{{ ansible_user_gid }}"
mode: '0644'
when: "'neovim' in ansible_facts.packages and disable_neovim_mouse_support"
mode: "0644"
when: "'neovim' in ansible_facts.packages and disable_neovim_mouse_support and not init_vim_stat.stat.exists"

- name: "Disable mouse support in neovim"
ansible.builtin.lineinfile:
Expand Down
1 change: 1 addition & 0 deletions tests/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
localhost
9 changes: 9 additions & 0 deletions tests/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

Check failure on line 1 in tests/test.yml

View workflow job for this annotation

GitHub Actions / Lint

1:1 [empty-lines] too many blank lines (1 > 0)
---
- name: "Test"
hosts: all
gather_facts: false
vars:
disable_neovim_mouse_support: true
roles:
- "../../ansible-role-linux_admin_packages"

0 comments on commit afa70cf

Please sign in to comment.