diff --git a/roles/pgadmin4/defaults/main.yml b/roles/pgadmin4/defaults/main.yml index 67c667b..2f0ff48 100644 --- a/roles/pgadmin4/defaults/main.yml +++ b/roles/pgadmin4/defaults/main.yml @@ -4,6 +4,6 @@ pga_id: 1 pga_port: 5050 pga_src_ip: [] pga_root_dir: /opt/pgadmin4_{{ pga_id }} -pga_version: '4.25' +pga_version: '4.26' pga_pip_url: https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v{{ pga_version }}/pip/pgadmin4-{{ pga_version }}-py3-none-any.whl pga_master_pass: False diff --git a/roles/pgadmin4/meta/main.yml b/roles/pgadmin4/meta/main.yml index cbce481..ed97d53 100644 --- a/roles/pgadmin4/meta/main.yml +++ b/roles/pgadmin4/meta/main.yml @@ -1,3 +1 @@ --- -dependencies: - - role: repo_scl diff --git a/roles/pgadmin4/tasks/conf.yml b/roles/pgadmin4/tasks/conf.yml index 20a1995..6d6d666 100644 --- a/roles/pgadmin4/tasks/conf.yml +++ b/roles/pgadmin4/tasks/conf.yml @@ -1,7 +1,7 @@ --- - name: Deploy local configuration - template: src=config_local.py.j2 dest={{ pga_root_dir }}/lib/python3.6/site-packages/pgadmin4/config_local.py + template: src=config_local.py.j2 dest={{ pga_root_dir }}/venv/lib/python3.6/site-packages/pgadmin4/config_local.py notify: restart pgadmin4 tags: pgadmin4 @@ -12,7 +12,7 @@ - name: Initial setup of pgadmin4 expect: - command: "{{ pga_root_dir }}/bin/python {{ pga_root_dir }}/lib/python3.6/site-packages/pgadmin4/setup.py" + command: "{{ pga_root_dir }}/venv/bin/python {{ pga_root_dir }}/venv/lib/python3.6/site-packages/pgadmin4/setup.py" echo: true responses: 'Email address:\s?': "admin@{{ ansible_domain }}" diff --git a/roles/pgadmin4/tasks/directories.yml b/roles/pgadmin4/tasks/directories.yml index 84728de..8c3e037 100644 --- a/roles/pgadmin4/tasks/directories.yml +++ b/roles/pgadmin4/tasks/directories.yml @@ -12,4 +12,6 @@ owner: pgadmin4_{{ pga_id }} - path: "{{ pga_root_dir }}/logs" owner: pgadmin4_{{ pga_id }} + - path: "{{ pga_root_dir }}/meta" + mode: 700 tags: pgadmin4 diff --git a/roles/pgadmin4/tasks/facts.yml b/roles/pgadmin4/tasks/facts.yml index 25a6ae1..2d1c21e 100644 --- a/roles/pgadmin4/tasks/facts.yml +++ b/roles/pgadmin4/tasks/facts.yml @@ -5,3 +5,12 @@ register: pga_venv_27 tags: pgadmin4 +- import_tasks: ../includes/webapps_set_install_mode.yml + vars: + - root_dir: "{{ pga_root_dir }}" + - version: "{{ pga_version }}" + tags: pgadmin4 +- set_fact: pga_install_mode={{ install_mode }} + tags: pgadmin4 +- set_fact: pga_current_version={{ current_version | default('') }} + tags: pgadmin4 diff --git a/roles/pgadmin4/tasks/install.yml b/roles/pgadmin4/tasks/install.yml index 84a8437..0843a32 100644 --- a/roles/pgadmin4/tasks/install.yml +++ b/roles/pgadmin4/tasks/install.yml @@ -6,8 +6,8 @@ - gcc - postgresql - postgresql-devel - - rh-python36-python-virtualenv - - rh-python36-python-pip + - python3-virtualenv + - python3-pip - python-setuptools # Needed for pip install expect - python-pip # Also needed to install expect tags: pgadmin4 @@ -31,6 +31,21 @@ when: pga_venv_27.stat.exists tags: pgadmin4 +- name: Wipe the venv on upgrade + file: path={{ pga_root_dir }}/{{ item }} state=absent + loop: + - lib + - lib64 + - include + - bin + - venv + when: pga_install_mode != 'none' + tags: pgadmin4 + +- name: Create the venv dir + file: path={{ pga_root_dir }}/venv state=directory + tags: pgadmin4 + - name: Create the virtualenv pip: name: @@ -39,19 +54,20 @@ - gunicorn - futures - psycopg2 - - werkzeug==0.16.1 - - ldap3==2.6.1 - state: latest - virtualenv: "{{ pga_root_dir }}" - virtualenv_command: /opt/rh/rh-python36/root/usr/bin/virtualenv + - werkzeug + - ldap3 + virtualenv: "{{ pga_root_dir }}/venv" + virtualenv_command: /usr/bin/virtualenv-3 + virtualenv_python: /usr/bin/python3 notify: restart pgadmin4 tags: pgadmin4 - name: Install pgadmin4 pip: name: "{{ pga_pip_url }}" - virtualenv: "{{ pga_root_dir }}" - virtualenv_command: /opt/rh/rh-python36/root/usr/bin/virtualenv + virtualenv: "{{ pga_root_dir }}/venv" + virtualenv_command: /usr/bin/virtualenv-3 + virtualenv_python: /usr/bin/python3 register: pga_pip notify: restart pgadmin4 tags: pgadmin4 diff --git a/roles/pgadmin4/tasks/main.yml b/roles/pgadmin4/tasks/main.yml index c87fd55..4511f65 100644 --- a/roles/pgadmin4/tasks/main.yml +++ b/roles/pgadmin4/tasks/main.yml @@ -8,4 +8,4 @@ - include: iptables.yml when: iptables_manage | default(True) - include: service.yml - +- include: write_version.yml diff --git a/roles/pgadmin4/tasks/write_version.yml b/roles/pgadmin4/tasks/write_version.yml new file mode 100644 index 0000000..5981f25 --- /dev/null +++ b/roles/pgadmin4/tasks/write_version.yml @@ -0,0 +1,6 @@ +--- + +- name: Write version + copy: content={{ pga_version }} dest={{ pga_root_dir }}/meta/ansible_version + tags: pgadmin4 + diff --git a/roles/pgadmin4/templates/pgadmin4.service.j2 b/roles/pgadmin4/templates/pgadmin4.service.j2 index 81923c7..75b6587 100644 --- a/roles/pgadmin4/templates/pgadmin4.service.j2 +++ b/roles/pgadmin4/templates/pgadmin4.service.j2 @@ -6,10 +6,10 @@ After=syslog.target network.target Type=simple User=pgadmin4_{{ pga_id }} Group=pgadmin4_{{ pga_id }} -ExecStart={{ pga_root_dir }}/bin/gunicorn --bind 0.0.0.0:{{ pga_port }} \ +ExecStart={{ pga_root_dir }}/venv/bin/gunicorn --bind 0.0.0.0:{{ pga_port }} \ --workers=1 \ --threads=25 \ - --chdir {{ pga_root_dir }}/lib/python3.6/site-packages/pgadmin4 \ + --chdir {{ pga_root_dir }}/venv/lib/python3.6/site-packages/pgadmin4 \ pgAdmin4:app ExecReload=/bin/kill -HUP $MAINPID PrivateTmp=yes