1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 19:52:06 +00:00
iiab/roles/phpmyadmin/tasks/main.yml

102 lines
3.3 KiB
YAML
Raw Normal View History

2020-05-20 23:38:09 +00:00
- name: "Set 'apache_install: True' and 'apache_enabled: True'"
set_fact:
apache_install: True
apache_enabled: True
- name: APACHE - run 'httpd' role
include_role:
name: httpd
2018-10-31 06:44:33 +00:00
- name: Download {{ iiab_download_url }}/{{ phpmyadmin_name_zip }} to {{ downloads_dir }}
2017-11-17 03:22:24 +00:00
get_url:
url: "{{ iiab_download_url }}/{{ phpmyadmin_name_zip }}"
dest: "{{ downloads_dir }}"
2017-12-08 06:28:52 +00:00
timeout: "{{ download_timeout }}"
when: internet_available | bool
2017-11-17 03:22:24 +00:00
2018-10-31 06:44:33 +00:00
- name: Does {{ downloads_dir }}/{{ phpmyadmin_name_zip }} exist? # e.g. /opt/iiab/downloads/phpMyAdmin-4.8.3-all-languages.zip
2017-11-17 03:22:24 +00:00
stat:
path: "{{ downloads_dir }}/{{ phpmyadmin_name_zip }}"
register: phpmyadmin_dl
- name: FAIL (force Ansible to exit) IF /opt/iiab/downloads/{{ phpmyadmin_name_zip }} doesn't exist
fail:
msg: "{{ downloads_dir }}/{{ phpmyadmin_name_zip }} is REQUIRED in order to install phpMyAdmin."
when: not phpmyadmin_dl.stat.exists
2020-01-24 02:59:51 +00:00
- name: Unzip to permanent location /opt/{{ phpmyadmin_name }}, owned by {{ apache_user }}
2017-11-17 03:22:24 +00:00
unarchive:
src: "{{ downloads_dir }}/{{ phpmyadmin_name_zip }}"
dest: /opt
owner: "{{ apache_user }}"
2020-01-24 02:59:51 +00:00
- name: Symlink /opt/phpmyadmin -> {{ phpmyadmin_name }}
2017-11-17 03:22:24 +00:00
file:
src: "{{ phpmyadmin_name }}"
2018-10-31 06:44:33 +00:00
path: /opt/phpmyadmin
2020-01-24 02:59:51 +00:00
owner: "{{ apache_user }}" # Some Linux's ignore symlink owners?
2017-11-17 03:22:24 +00:00
state: link
2020-01-24 02:59:51 +00:00
- name: Install /opt/phpmyadmin/config.inc.php owned by {{ apache_user }}, from template
2017-11-17 03:22:24 +00:00
template:
src: config.inc.php
dest: /opt/phpmyadmin/config.inc.php
owner: "{{ apache_user }}"
# Above 3 stanzas set link/tree/contents ownership to {{ apache_user }}:root
# OOPS: CHOWN BELOW CHANGED LINK ALONE (TREE/CONTENTS REMAINED root:root)
# - name: Change the owner of the PHP tree to Apache
# shell: "chown -R {{ apache_user }} /opt/phpmyadmin"
# #file:
# # path: "/opt/{{ phpmyadmin_name_zip }}"
# # owner: "{{ apache_user }}"
# # recurse: yes
# # state: directory
2020-01-30 09:00:00 +00:00
- name: Install /etc/{{ apache_conf_dir }}/phpmyadmin.conf from template, if phpmyadmin_enabled
template:
src: phpmyadmin.j2
dest: "/etc/{{ apache_conf_dir }}/phpmyadmin.conf"
2020-05-20 23:38:09 +00:00
when: apache_installed is defined
2020-01-30 09:00:00 +00:00
# RECORD phpMyAdmin AS INSTALLED
- name: "Set 'phpmyadmin_installed: True'"
set_fact:
phpmyadmin_installed: True
2020-01-24 02:59:51 +00:00
- name: "Add 'phpmyadmin_installed: True' to {{ iiab_state_file }}"
lineinfile:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
2020-01-24 02:59:51 +00:00
regexp: '^phpmyadmin_installed'
line: 'phpmyadmin_installed: True'
2020-01-30 09:00:00 +00:00
- name: Enable phpMyAdmin via Apache, if phpmyadmin_enabled
command: a2ensite phpmyadmin.conf
2020-05-20 23:38:09 +00:00
when: apache_installed is defined and phpmyadmin_enabled
2017-11-17 03:22:24 +00:00
2020-01-30 09:00:00 +00:00
- name: Disable phpMyAdmin via Apache, if not phpmyadmin_enabled
command: a2dissite phpmyadmin.conf
2020-05-20 23:38:09 +00:00
when: apache_installed is defined and not phpmyadmin_enabled
2017-11-17 03:22:24 +00:00
2020-01-24 02:59:51 +00:00
2018-10-31 06:44:33 +00:00
- name: Add 'phpmyadmin' variable values to {{ iiab_ini_file }}
2017-11-17 03:22:24 +00:00
ini_file:
2018-10-31 06:44:33 +00:00
path: "{{ iiab_ini_file }}"
2017-11-17 03:22:24 +00:00
section: phpmyadmin
option: "{{ item.option }}"
value: "{{ item.value | string }}"
2017-11-17 03:22:24 +00:00
with_items:
2017-12-08 06:28:52 +00:00
- option: name
value: phpMyAdmin
- option: description
value: '"phpMyAdmin is an interface with a MySQL database written in PHP, and available to administer the database engine locally or across the network."'
- option: path
value: /opt/phpmyadmin
- option: enabled
value: "{{ phpmyadmin_enabled }}"