mirror of
				https://git.lapiole.org/dani/ansible-roles.git
				synced 2025-10-31 19:01:28 +01:00 
			
		
		
		
	Update to 2021-12-01 19:13
This commit is contained in:
		
							
								
								
									
										37
									
								
								roles/pgadmin4/tasks/conf.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								roles/pgadmin4/tasks/conf.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| --- | ||||
|  | ||||
| - name: Deploy local configuration | ||||
|   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 | ||||
|  | ||||
| - name: Check if the config DB exists | ||||
|   stat: path={{ pga_root_dir }}/data/pgadmin4.db | ||||
|   register: pga_db | ||||
|   tags: pgadmin4 | ||||
|  | ||||
| - name: Initial setup of pgadmin4 | ||||
|   expect: | ||||
|     command: "{{ pga_root_dir }}/venv/bin/python {{ pga_root_dir }}/venv/lib/python3.6/site-packages/pgadmin4/setup.py" | ||||
|     timeout: 120 | ||||
|     echo: true | ||||
|     responses: | ||||
|       'Email address:\s?': "admin@{{ ansible_domain }}" | ||||
|       '(Retype )?[Pp]assword:\s?': "pgadmin" | ||||
|   become_user: pgadmin4_{{ pga_id }} | ||||
|   when: | ||||
|     - not pga_db.stat.exists | ||||
|     - pga_auth | length >= 1 | ||||
|   tags: pgadmin4 | ||||
|  | ||||
| - name: Initial setup of pgAdmin4 | ||||
|   command: "{{ pga_root_dir }}/venv/bin/python {{ pga_root_dir }}/venv/lib/python3.6/site-packages/pgadmin4/setup.py" | ||||
|   become_user: pgadmin4_{{ pga_id }} | ||||
|   when: | ||||
|     - not pga_db.stat.exists | ||||
|     - pga_auth | length < 1 | ||||
|   tags: pgadmin4 | ||||
|  | ||||
| - name: Configure logrotate | ||||
|   template: src=logrotate.conf.j2 dest=/etc/logrotate.d/pgadmin4_{{ pga_id }} | ||||
|   tags: pgadmin4 | ||||
							
								
								
									
										19
									
								
								roles/pgadmin4/tasks/directories.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								roles/pgadmin4/tasks/directories.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| --- | ||||
|  | ||||
| - name: Create directories | ||||
|   file: path={{ item.path }} state=directory owner={{ item.owner | default(omit) }} group={{ item.group | default(omit) }} mode={{ item.mode | default(omit) }} | ||||
|   with_items: | ||||
|     - path: "{{ pga_root_dir }}" | ||||
|       owner: pgadmin4_{{ pga_id }} | ||||
|       mode: 700 | ||||
|     - path: "{{ pga_root_dir }}/sessions" | ||||
|       owner: pgadmin4_{{ pga_id }} | ||||
|     - path: "{{ pga_root_dir }}/data" | ||||
|       owner: pgadmin4_{{ pga_id }} | ||||
|     - path: "{{ pga_root_dir }}/logs" | ||||
|       owner: pgadmin4_{{ pga_id }} | ||||
|     - path: "{{ pga_root_dir }}/meta" | ||||
|       mode: 700 | ||||
|     - path: "{{ pga_root_dir }}/backup" | ||||
|       mode: 700 | ||||
|   tags: pgadmin4 | ||||
							
								
								
									
										23
									
								
								roles/pgadmin4/tasks/facts.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								roles/pgadmin4/tasks/facts.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| --- | ||||
|  | ||||
| - include_vars: "{{ item }}" | ||||
|   with_first_found: | ||||
|     - vars/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml | ||||
|     - vars/{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml | ||||
|     - vars/{{ ansible_distribution }}.yml | ||||
|     - vars/{{ ansible_os_family }}.yml | ||||
|   tags: pgadmin4 | ||||
|  | ||||
| - name: Check if a 2.7 venv exists | ||||
|   stat: path={{ pga_root_dir }}/lib/python2.7 | ||||
|   register: pga_venv_27 | ||||
|   tags: pgadmin4 | ||||
|  | ||||
| - block: | ||||
|     - import_tasks: ../includes/webapps_set_install_mode.yml | ||||
|       vars: | ||||
|         - root_dir: "{{ pga_root_dir }}" | ||||
|         - version: "{{ pga_version }}" | ||||
|     - set_fact: pga_install_mode={{ install_mode }} | ||||
|     - set_fact: pga_current_version={{ current_version | default('') }} | ||||
|   tags: pgadmin4 | ||||
							
								
								
									
										83
									
								
								roles/pgadmin4/tasks/install.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								roles/pgadmin4/tasks/install.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,83 @@ | ||||
| --- | ||||
|  | ||||
| - name: Install packages | ||||
|   yum: name={{ pgadmin4_packages }} | ||||
|   tags: pgadmin4 | ||||
|  | ||||
| - name: Install global python tools | ||||
|   pip: name=pexpect | ||||
|   tags: pgadmin4 | ||||
|  | ||||
| - name: Stop pgAdmin4 | ||||
|   service: name=pgadmin4_{{ pga_id }} state=stopped | ||||
|   when: pga_venv_27.stat.exists | ||||
|   tags: pgadmin4 | ||||
|  | ||||
| - name: Remove the venv | ||||
|   file: path={{ pga_root_dir }}/{{ item }} state=absent | ||||
|   loop: | ||||
|     - lib | ||||
|     - lib64 | ||||
|     - include | ||||
|     - bin | ||||
|   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: | ||||
|       - pip | ||||
|       - virtualenv | ||||
|       - gunicorn | ||||
|       - futures | ||||
|       - psycopg2 | ||||
|       - 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 }}/venv" | ||||
|     virtualenv_command: /usr/bin/virtualenv-3 | ||||
|     virtualenv_python: /usr/bin/python3 | ||||
|   register: pga_pip | ||||
|   notify: restart pgadmin4 | ||||
|   tags: pgadmin4 | ||||
|  | ||||
| - name: Deploy systemd unit | ||||
|   template: src=pgadmin4.service.j2 dest=/etc/systemd/system/pgadmin4_{{ pga_id }}.service | ||||
|   register: pga_systemd_unit | ||||
|   notify: restart pgadmin4 | ||||
|   tags: pgadmin4 | ||||
|  | ||||
| - name: Reload systemd | ||||
|   command: systemctl daemon-reload | ||||
|   when: pga_systemd_unit.changed | ||||
|   tags: pgadmin4 | ||||
|  | ||||
| - name: Install backup hooks | ||||
|   template: src={{ item }}-backup.j2 dest=/etc/backup/{{ item }}.d/pgadmin4_{{ pga_id }} mode=755 | ||||
|   loop: | ||||
|     - pre | ||||
|     - post | ||||
|   tags: pgadmin4 | ||||
							
								
								
									
										8
									
								
								roles/pgadmin4/tasks/iptables.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								roles/pgadmin4/tasks/iptables.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| --- | ||||
|  | ||||
| - name: Handle pgAdmin4 port | ||||
|   iptables_raw: | ||||
|     name: pga_port | ||||
|     state: "{{ (pga_src_ip | length > 0) | ternary('present','absent') }}" | ||||
|     rules: "-A INPUT -m state --state NEW -p tcp --dport {{ pga_port }} -s {{ pga_src_ip | join(',') }} -j ACCEPT" | ||||
|   tags: pgadmin4 | ||||
							
								
								
									
										11
									
								
								roles/pgadmin4/tasks/main.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								roles/pgadmin4/tasks/main.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| --- | ||||
|  | ||||
| - include: facts.yml | ||||
| - include: user.yml | ||||
| - include: directories.yml | ||||
| - include: install.yml | ||||
| - include: conf.yml | ||||
| - include: iptables.yml | ||||
|   when: iptables_manage | default(True) | ||||
| - include: service.yml | ||||
| - include: write_version.yml | ||||
							
								
								
									
										6
									
								
								roles/pgadmin4/tasks/service.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								roles/pgadmin4/tasks/service.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| --- | ||||
|  | ||||
| - name: Start and enable the daemon | ||||
|   service: name=pgadmin4_{{ pga_id }} state=started enabled=True | ||||
|   register: pgadmin4_started | ||||
|   tags: pgadmin4 | ||||
							
								
								
									
										10
									
								
								roles/pgadmin4/tasks/user.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								roles/pgadmin4/tasks/user.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| --- | ||||
| - name: Create a useraccount | ||||
|   user: | ||||
|     name: pgadmin4_{{ pga_id }} | ||||
|     comment: "PgAdmin4 User Account" | ||||
|     system: True | ||||
|     shell: /sbin/nologin | ||||
|     home: "{{ pga_root_dir }}" | ||||
|   tags: pgadmin4 | ||||
|  | ||||
							
								
								
									
										6
									
								
								roles/pgadmin4/tasks/write_version.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								roles/pgadmin4/tasks/write_version.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| --- | ||||
|  | ||||
| - name: Write version | ||||
|   copy: content={{ pga_version }} dest={{ pga_root_dir }}/meta/ansible_version | ||||
|   tags: pgadmin4 | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Daniel Berteaud
					Daniel Berteaud