ansible-role-pgadmin/tasks/pgadmin_pip.yml

56 lines
2.1 KiB
YAML

---
- block:
- name: Create a user that will be the owner of the pgadmin files
user: name={{ pgadmin_user }} home={{ pgadmin_home }} createhome=no shell=/usr/sbin/nologin system=yes
- name: Create the pgadmin installation directory
file: dest={{ pgadmin_home }} state=directory
- name: Create the pgadmin log directory
file: dest=/var/log/pgadmin state=directory owner={{ pgadmin_user }} group={{ pgadmin_user }}
- name: Create the directories that must be writeable by pgadmin
file: dest={{ pgadmin_home }}/{{ item }} state=directory owner={{ pgadmin_user }} group={{ pgadmin_user }}
with_items: '{{ pgadmin_writeable_dirs }}'
- name: Create the mailman virtualenv. Manually, because python 3.6
shell: cd '{{ pgadmin_home }}' && python3 -m venv '{{ pgadmin_venv_name }}'
args:
creates: '{{ pgadmin_venv_bindir }}/activate'
- name: Install the required packages in the pgadmin virtualenv
pip:
executable: '{{ pgadmin_venv_bindir }}/pip3'
#virtualenv_command: 'virtualenv-3'
virtualenv_site_packages: no
name: '{{ item.pkg }}'
extra_args: "{{ item.extra_args | default('') }}"
version: "{{ item.version | default('') }}"
editable: no
with_items: '{{ pgadmin_pip_pkgs }}'
- name: Install the pgadmin configuration file
template: src=config_local.py.j2 dest={{ pgadmin_workdir }}/config_local.py owner=root group=root
- name: run the pgadmin setup if we just installed the pip modules
become: True
become_user: '{{ pgadmin_user }}'
shell: cd {{ pgadmin_workdir }} && {{ pgadmin_venv_bindir }}/python3 setup.py
args:
creates: '{{ pgadmin_home }}/db/pgadmin.db'
- name: Install the pgAdmin systemd unit
template: src=pgadmin.service.systemd.j2 dest=/etc/systemd/system/pgadmin.service
register: systemd_reload
- name: systemd reload
command: systemctl daemon-reload
when: systemd_reload is changed
- name: Ensure that the pgAdmin service is enabled and running
service: name=pgadmin state=started enabled=yes
when: pgadmin_via_pip
tags: [ 'pgadmin' ]