Skip to content

Commit

Permalink
Merge pull request #26 from ctorgalson/pr25-fix-intermittent-non-zero…
Browse files Browse the repository at this point in the history
…-return-code

Pr25 fix intermittent non zero return code
  • Loading branch information
ctorgalson authored Jun 17, 2022
2 parents f34f03e + 1420f66 commit efb7d82
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 41 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
jobs:
molecule:
runs-on: ubuntu-latest
env:
ANSIBLE_ASYNC_DIR: "/tmp/.ansible_async"
strategy:
fail-fast: false
matrix:
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ The following variables are used in the role. See also Example Playbook
| `vim_installed_packages` | `["vim"]` | A list of packages to install (passed to Ansible's Package module). |
| `vim_removed_packages` | `[]` | A list of packages to remove (e.g. on Ubuntu, it might be preferable to remove `vim-tiny`). |
| `vim_owner` | `""` | The system user to install Vim and/or associated plugins for. |
| `vim_group` | `""` | The group of the user specificed in `vim_owner`. |
| `vim_file_mode` | `'644'` | The permissions string to set on files copied or created by the role. |
| `vim_dir_mode` | `'755'` | The permissions string to set on directories copied or created by the role. |
| `vim_pack_subdirectory` | `ansible-managed` | The name of the directory to place plugins installed by this role into the default creates e.g. `~/.vim/pack/ansible-managed/start` and `~/.vim/pack/ansible-managed/opt`. |
| `vim_installed_plugins` | `[]` | The list of plugins to install to `~/.vim/pack/ansible-managed/start`--see `:help packages` for details on what this means. Should contain a `repo` property, a `type` property set to either 'start' or 'opt', and (optionally) a `version` property as used by Ansible's Git module. |
| `vim_removed_plugins` | `[]` | A list of plugins to remove from `~/.vim/pack/ansible-managed/{opt,start}`. Each should contain a directory property set to the directory name of the plugin, and a `type` property set to either 'start' or 'opt'. |
Expand All @@ -56,7 +53,6 @@ The following variables are used in the role. See also Example Playbook
vim_removed_packages:
- "vim-tiny"
vim_owner: "molecule"
vim_group: "molecule"
vim_installed_plugins:
- repo: "https://github.com/altercation/vim-colors-solarized.git"
type: "start"
Expand Down
3 changes: 0 additions & 3 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ vim_installed_packages:
- "vim"
vim_removed_packages: []
vim_owner: ""
vim_group: ""
# vim_file_mode: "644"
# vim_dir_mode: "755"
vim_pack_subdirectory: "ansible-managed"
vim_installed_plugins: []
# - repo: "https://github.com/scrooloose/nerdtree.git"
Expand Down
1 change: 0 additions & 1 deletion molecule/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
vim_removed_packages:
- "vim-tiny"
vim_owner: "molecule"
vim_group: "molecule"
vim_dotfiles:
- "{{ playbook_dir }}/files/dotfiles/.vimrc"
tasks:
Expand Down
2 changes: 2 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ platforms:
pre_build_image: true
provisioner:
name: ansible
env:
ANSIBLE_ASYNC_DIR: "/tmp/ansible_async_dir"
playbooks:
prepare: ../prepare.yml
converge: ../converge.yml
Expand Down
8 changes: 3 additions & 5 deletions molecule/tests/test-config-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@
(not rg__config_file.stat.exists and config_file.state == 'absent')
fail_msg: "The config file '{{ config_file_name }}' is not {{ config_file.state }}."

- name: "Verify owner, group, and mode of '{{ config_file_name }}'."
- name: "Verify owner and group of '{{ config_file_name }}'."
assert:
that:
- "rg__config_file.stat.pw_name == fact__vim_owner"
- "rg__config_file.stat.gr_name == fact__vim_owner"
- "rg__config_file.stat.mode == config_file.mode"
fail_msg: >
The owner, group, or mode of the '{{ config_file }}' file was
The owner or group of the '{{ config_file }}' file was
incorrect. Found {{ rg__config_file.stat.pw_name }} (owner),
{{ rg__config_file.stat.gr_name }} (group), and
{{ rg__config_file.stat.mode }} (mode).
{{ rg__config_file.stat.gr_name }} (group).
8 changes: 3 additions & 5 deletions molecule/tests/test-directories.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@
that:
- "rg__dir_path.stat.pw_name == fact__vim_owner"
- "rg__dir_path.stat.gr_name == fact__vim_owner"
- "rg__dir_path.stat.mode == dir.mode"
fail_msg: >
The owner, group, or mode of the '{{ dir_name }}' {{ dir.type }} was
incorrect. Found {{ rg__dir_path.stat.pw_name }} (owner),
{{ rg__dir_path.stat.gr_name }} (group), and
{{ rg__dir_path.stat.mode }} (mode).
The owner or group of the '{{ dir_name }}' {{ dir.type }} was
incorrect. Found owner '{{ rg__dir_path.stat.pw_name }}' ({{ fact__vim_owner }}),
group '{{ rg__dir_path.stat.gr_name }}' ({{ fact__vim_owner }}).
when: "rg__dir_path.stat.exists and dir.state == 'present'"
10 changes: 4 additions & 6 deletions molecule/tests/test-helptags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
that: "rg__plugin_tags.stat.exists"
fail_msg: "No helptags file was found for the '{{ plugin_name }}' plugin."

- name: "Verify owner, group, and mode of '{{ plugin_name }}' plugin helptags file."
- name: "Verify owner and group of '{{ plugin_name }}' plugin helptags file."
assert:
that:
- "rg__plugin_tags.stat.pw_name == fact__vim_owner"
- "rg__plugin_tags.stat.gr_name == fact__vim_owner"
- "rg__plugin_tags.stat.mode == '0664'"
fail_msg: >
The owner, group, or mode of the '{{ plugin_name }}' plugin helptags
file was incorrect. Found {{ rg__plugin_tags.stat.pw_name }} (owner),
{{ rg__plugin_tags.stat.gr_name }} (group), and
{{ rg__plugin_tags.stat.mode }} (mode).
The owner or group of the '{{ plugin_name }}' plugin helptags
file was incorrect. Found owner '{{ rg__plugin_tags.stat.pw_name }}' ({{ fact__vim_owner }}),
and group '{{ rg__plugin_tags.stat.gr_name }}' ({{ fact__vim_owner }}).
8 changes: 0 additions & 8 deletions molecule/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,30 @@
fact__vim_config_files:
- path: "{{ fact__vim_home_directory }}/.vimrc"
state: present
mode: "0644"
fact__vim_directories:
- path: "{{ fact__vim_home_directory }}/.vim/pack/ansible-managed"
state: present
type: "directory"
mode: "0755"
- path: "{{ fact__vim_home_directory }}/.vim/pack/ansible-managed/start"
state: present
type: "directory"
mode: "0755"
- path: "{{ fact__vim_home_directory }}/.vim/pack/ansible-managed/opt"
state: present
type: "directory"
mode: "0755"
fact__vim_plugins:
# Installed plugins.
- path: "{{ fact__vim_home_directory }}/.vim/pack/ansible-managed/opt/vdebug"
state: present
type: "plugin"
mode: "0775"
- path: "{{ fact__vim_home_directory }}/.vim/pack/ansible-managed/start/vim-airline"
state: present
type: "plugin"
mode: "0775"
- path: "{{ fact__vim_home_directory }}/.vim/pack/ansible-managed/start/lightline.vim"
state: present
type: "plugin"
mode: "0775"
- path: "{{ fact__vim_home_directory }}/.vim/pack/ansible-managed/start/vim-colors-solarized"
state: present
type: "plugin"
mode: "0775"
# Removed plugins.
- path: "{{ fact__vim_home_directory }}/.vim/pack/ansible-managed/opt/tabular"
state: absent
Expand Down
3 changes: 0 additions & 3 deletions tasks/copy-dotfiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
ansible.builtin.copy:
src: "{{ dotfile }}"
dest: "{{ vim_user_home_directory }}/{{ dotfile | basename }}"
owner: "{{ vim_owner }}"
group: "{{ vim_group }}"
mode: "{{ vim_file_mode | default('644') }}"
become: true
become_user: "{{ vim_owner }}"
loop: "{{ vim_dotfiles }}"
Expand Down
9 changes: 3 additions & 6 deletions tasks/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
# setup tasks for ansible-role-vim.

- name: Get Vim version.
ansible.builtin.shell: "set -o pipefail && vim --version | head -n1 | awk '{ print $5 }'"
ansible.builtin.shell: "set -o pipefail && (vim --version | head -n1 | awk '{ print $5 }') || test $? -eq 141"
args:
executable: "/bin/bash"
warn: false
register: vim_version_string
changed_when: false

- name: Make sure it even makes sense to continue.
ansible.builtin.assert:
that: "{{ vim_version_string.stdout is version('8.0', '>=') }}"
ansible.builtin.fail:
msg: "Vim does not support native package management in versions lower than 8.0."
when: "{{ vim_version_string.stdout is version('8.0', '<') }}"

- name: Determine home directory.
ansible.builtin.set_fact:
Expand All @@ -38,9 +38,6 @@
ansible.builtin.file:
path: "{{ vim_plugin_parent_directory }}/{{ vim_directory }}"
state: directory
owner: "{{ vim_owner }}"
group: "{{ vim_group }}"
mode: "{{ vim_dir_mode | default('755') }}"
become: true
become_user: "{{ vim_owner }}"
loop:
Expand Down

0 comments on commit efb7d82

Please sign in to comment.