Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to enable plugins via ansible. #201

Merged
merged 1 commit into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ An ansible playbook could be used to install `recap` from a git repository. The
- `prefix` - The value of *PREFIX*, default: `/usr`.
- `tmp_install_dir` - The location where the cloned repo will be placed, default: `/tmp/recap`.
- `uninstall` - Then this is defined it will remove `recap`, default: *undefined*.
- `enable_plugins` - To enable the global plugin configuration default: `false`.
- `plugin_list` - A list of plugins to enable, from the `plugin-available` directory, default: `all`.

#### Install (default)

Expand All @@ -179,6 +181,23 @@ Install recap with *BINPATH* in `/bin`:

```
ansible-playbook tools/ansible_recap.yml -e binpath=/bin

```

Install recap with all plugins enabled:

```
ansible-playbook tools/ansible_recap.yml -e enable_plugins=true

```

Install recap with a list of plugins to enable:

```
ansible-playbook tools/ansible_recap.yml \
-e enable_plugins=true \
-e '{"plugin_list":[docker_top,redis]}'

```

#### Uninstall
Expand Down
40 changes: 40 additions & 0 deletions tools/ansible_recap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
- git
- make
systemd_unit_dir: "{{ destdir }}/usr/lib/systemd/system"
enable_plugins: "no"
plugin_list:
- all
tasks:
- name: Set dependencies and timers
set_fact:
Expand Down Expand Up @@ -56,6 +59,43 @@
DESTDIR: "{{ destdir }}"
PREFIX: "{{ prefix }}"

- name: Enabling plugins
block:
- name: Finding all plugins available
block:
- name: Find all plugins
find:
paths: "{{ prefix }}/lib/recap/plugins-available"
register: plugins_found

- name: Create plugin list with all plugins found
set_fact:
plugin_list: "{{ plugin_list + [ item.path | basename ] }}"
with_items: "{{ plugins_found.files }}"
when: plugins_found.matched

- name: Remove "all" from list
set_fact:
plugin_list: "{{ plugin_list | difference(['all']) }}"

when: "'all' in plugin_list"

- name: enable plugins in global config
lineinfile:
path: /etc/recap.conf
insertafter: '#USEPLUGINS="no"'
line: 'USEPLUGINS="yes"'
state: present

- name: enable list of plugins
file:
dest: "{{ prefix }}/lib/recap/plugins-enabled/{{ item }}"
src: "{{ prefix }}/lib/recap/plugins-available/{{ item }}"
state: link
with_items: "{{ plugin_list }}"

when: enable_plugins

- name: Enable systemd timers
systemd:
name: "{{ item }}"
Expand Down