From e8683079b0ebf56ae049ab8988290a360c45de99 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 14 Sep 2019 17:52:02 -0500 Subject: [PATCH] lokole - iiab_installed --- roles/lokole/tasks/enable.yml | 65 ++++++++++++++++++++++++++++++++++ roles/lokole/tasks/install.yml | 62 ++++---------------------------- roles/lokole/tasks/main.yml | 6 +++- 3 files changed, 76 insertions(+), 57 deletions(-) create mode 100644 roles/lokole/tasks/enable.yml diff --git a/roles/lokole/tasks/enable.yml b/roles/lokole/tasks/enable.yml new file mode 100644 index 000000000..fe60530a4 --- /dev/null +++ b/roles/lokole/tasks/enable.yml @@ -0,0 +1,65 @@ +- name: Enable & Restart 'lokole' systemd service, with daemon_reload, if lokole_enabled + systemd: + daemon_reload: yes + name: lokole + enabled: yes + state: restarted + when: lokole_enabled | bool + +- name: Disable 'lokole' service, if not lokole_enabled + systemd: + daemon_reload: yes + name: lokole + enabled: no + state: stopped + when: not lokole_enabled + +- name: Install /etc/{{ apache_config_dir }}/lokole.conf from template, for http://box/lokole + template: + src: lokole.conf.j2 + dest: "/etc/{{ apache_config_dir }}/lokole.conf" + +- name: Symlink /etc/apache2/sites-enabled/lokole.conf to /etc/{{ apache_config_dir }}/lokole.conf, if lokole_enabled (debuntu) + file: + src: "/etc/{{ apache_config_dir }}/lokole.conf" + path: /etc/apache2/sites-enabled/lokole.conf + state: link + when: lokole_enabled and is_debuntu + +- name: Remove /etc/apache2/sites-enabled/lokole.conf, if not lokole_enabled (debuntu) + file: + path: /etc/apache2/sites-enabled/lokole.conf + state: absent + when: not lokole_enabled and is_debuntu + +- name: Remove /etc/{{ apache_config_dir }}/lokole.conf, if not lokole_enabled (OS's other than debuntu) + file: + path: "/etc/{{ apache_config_dir }}/lokole.conf" + state: absent + when: (not lokole_enabled) and (not is_debuntu) + +- name: Restart Apache ({{ apache_service }}) to enable/disable http://box/lokole + systemd: + daemon_reload: yes + name: "{{ apache_service }}" + state: restarted + +- name: Add 'lokole' variable values to {{ iiab_ini_file }} + ini_file: + path: "{{ iiab_ini_file }}" + section: lokole + option: "{{ item.option }}" + value: "{{ item.value }}" + with_items: + - option: name + value: lokole + - option: description + value: '"Lokole is an email service that works offline, for rural communities."' + - option: lokole_run_directory + value: "{{ lokole_run_directory }}" + - option: lokole_url + value: "{{ lokole_url }}" + - option: lokole_full_url + value: "{{ lokole_full_url }}" + - option: lokole_enabled + value: "{{ lokole_enabled }}" diff --git a/roles/lokole/tasks/install.yml b/roles/lokole/tasks/install.yml index 194472ac6..b735a7f40 100644 --- a/roles/lokole/tasks/install.yml +++ b/roles/lokole/tasks/install.yml @@ -98,59 +98,9 @@ state: restarted when: lokole_enabled | bool -- name: Disable 'lokole' service, if not lokole_enabled - systemd: - name: lokole - enabled: no - state: stopped - when: not lokole_enabled - -- name: Install /etc/{{ apache_config_dir }}/lokole.conf from template, for http://box/lokole - template: - src: lokole.conf.j2 - dest: "/etc/{{ apache_config_dir }}/lokole.conf" - -- name: Symlink /etc/apache2/sites-enabled/lokole.conf to /etc/{{ apache_config_dir }}/lokole.conf, if lokole_enabled (debuntu) - file: - src: "/etc/{{ apache_config_dir }}/lokole.conf" - path: /etc/apache2/sites-enabled/lokole.conf - state: link - when: lokole_enabled and is_debuntu - -- name: Remove /etc/apache2/sites-enabled/lokole.conf, if not lokole_enabled (debuntu) - file: - path: /etc/apache2/sites-enabled/lokole.conf - state: absent - when: not lokole_enabled and is_debuntu - -- name: Remove /etc/{{ apache_config_dir }}/lokole.conf, if not lokole_enabled (OS's other than debuntu) - file: - path: "/etc/{{ apache_config_dir }}/lokole.conf" - state: absent - when: (not lokole_enabled) and (not is_debuntu) - -- name: Restart Apache ({{ apache_service }}) to enable/disable http://box/lokole - systemd: - daemon_reload: yes - name: "{{ apache_service }}" - state: restarted - -- name: Add 'lokole' variable values to {{ iiab_ini_file }} - ini_file: - path: "{{ iiab_ini_file }}" - section: lokole - option: "{{ item.option }}" - value: "{{ item.value }}" - with_items: - - option: name - value: lokole - - option: description - value: '"Lokole is an email service that works offline, for rural communities."' - - option: lokole_run_directory - value: "{{ lokole_run_directory }}" - - option: lokole_url - value: "{{ lokole_url }}" - - option: lokole_full_url - value: "{{ lokole_full_url }}" - - option: lokole_enabled - value: "{{ lokole_enabled }}" +- name: Add 'lokole_installed' variable values to {{ iiab_installed }} + lineinfile: + dest: "{{ iiab_installed }}" + regexp: '^lokole_installed' + line: 'lokole_installed' + state: present diff --git a/roles/lokole/tasks/main.yml b/roles/lokole/tasks/main.yml index 5f05bd4a3..159a92485 100644 --- a/roles/lokole/tasks/main.yml +++ b/roles/lokole/tasks/main.yml @@ -1,3 +1,7 @@ - name: Install Lokole {{ lokole_version }} if lokole_install include_tasks: install.yml - when: lokole_install | bool + when: lokole_install | bool and not lokole_installed is defined + +- name: Enable Lokole + include_tasks: enable.yml + when: lokole_install | bool or lokole_installed is defined