mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
odbc: add Arch Linux support via AUR psqlodbc (#11944)
* test(odbc): add Arch Linux support via AUR psqlodbc Fixes #4267 * test(setup_postgresql_db): guard Arch Linux initdb with creates * test(odbc): add setup_remote_tmp_dir dependency
This commit is contained in:
15
tests/integration/targets/odbc/handlers/main.yml
Normal file
15
tests/integration/targets/odbc/handlers/main.yml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
# Copyright (c) Ansible Project
|
||||||
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
- name: Remove user odbcbuilder
|
||||||
|
ansible.builtin.user:
|
||||||
|
name: odbcbuilder
|
||||||
|
state: absent
|
||||||
|
remove: true
|
||||||
|
|
||||||
|
- name: Remove odbcbuilder sudoers
|
||||||
|
community.general.sudoers:
|
||||||
|
name: odbcbuilder
|
||||||
|
state: absent
|
||||||
@@ -5,4 +5,5 @@
|
|||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- setup_pkg_mgr
|
- setup_pkg_mgr
|
||||||
|
- setup_remote_tmp_dir
|
||||||
- setup_postgresql_db
|
- setup_postgresql_db
|
||||||
|
|||||||
56
tests/integration/targets/odbc/tasks/install_arch_odbc.yml
Normal file
56
tests/integration/targets/odbc/tasks/install_arch_odbc.yml
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
---
|
||||||
|
# Copyright (c) Ansible Project
|
||||||
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
# psqlodbc is only available in the AUR on Arch Linux, so we must build it.
|
||||||
|
# makepkg cannot run as root, so we create a temporary build user with sudo.
|
||||||
|
|
||||||
|
- name: Create AUR build user
|
||||||
|
ansible.builtin.user:
|
||||||
|
name: odbcbuilder
|
||||||
|
state: present
|
||||||
|
notify: Remove user odbcbuilder
|
||||||
|
|
||||||
|
- name: Grant sudo powers to build user
|
||||||
|
community.general.sudoers:
|
||||||
|
name: odbcbuilder
|
||||||
|
user: odbcbuilder
|
||||||
|
commands: ALL
|
||||||
|
nopassword: true
|
||||||
|
notify: Remove odbcbuilder sudoers
|
||||||
|
|
||||||
|
- name: Install AUR build dependencies
|
||||||
|
ansible.builtin.package:
|
||||||
|
name:
|
||||||
|
- base-devel
|
||||||
|
- git
|
||||||
|
- postgresql-libs
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Allow build user to write to remote_tmp_dir
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ remote_tmp_dir }}"
|
||||||
|
mode: "0777"
|
||||||
|
|
||||||
|
- name: Create build directory for psqlodbc
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ remote_tmp_dir }}/odbcbuilder/psqlodbc"
|
||||||
|
owner: odbcbuilder
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: Clone psqlodbc from AUR
|
||||||
|
become: true
|
||||||
|
become_user: odbcbuilder
|
||||||
|
ansible.builtin.git:
|
||||||
|
repo: https://aur.archlinux.org/psqlodbc.git
|
||||||
|
dest: "{{ remote_tmp_dir }}/odbcbuilder/psqlodbc"
|
||||||
|
depth: 1
|
||||||
|
|
||||||
|
- name: Build and install psqlodbc
|
||||||
|
become: true
|
||||||
|
become_user: odbcbuilder
|
||||||
|
ansible.builtin.command:
|
||||||
|
chdir: "{{ remote_tmp_dir }}/odbcbuilder/psqlodbc"
|
||||||
|
cmd: makepkg -si --noconfirm
|
||||||
@@ -12,7 +12,6 @@
|
|||||||
msg: "{{ ansible_facts.os_family }} / {{ ansible_facts.distribution }} / {{ ansible_facts.distribution_major_version }}"
|
msg: "{{ ansible_facts.os_family }} / {{ ansible_facts.distribution }} / {{ ansible_facts.distribution_major_version }}"
|
||||||
|
|
||||||
- when:
|
- when:
|
||||||
- ansible_facts.os_family != 'Archlinux' # TODO install driver from AUR: https://aur.archlinux.org/packages/psqlodbc
|
|
||||||
- ansible_facts.distribution != 'Debian' or ansible_facts.distribution_major_version != '13' # TODO fix tests for Debian 13 (Trixie)!
|
- ansible_facts.distribution != 'Debian' or ansible_facts.distribution_major_version != '13' # TODO fix tests for Debian 13 (Trixie)!
|
||||||
block:
|
block:
|
||||||
|
|
||||||
@@ -23,6 +22,12 @@
|
|||||||
- include_tasks: no_pyodbc.yml
|
- include_tasks: no_pyodbc.yml
|
||||||
when: ansible_facts.os_family != 'FreeBSD' and ansible_facts.os_family != 'Suse' and ansible_facts.os_family != 'Debian'
|
when: ansible_facts.os_family != 'FreeBSD' and ansible_facts.os_family != 'Suse' and ansible_facts.os_family != 'Debian'
|
||||||
|
|
||||||
|
#
|
||||||
|
# Install PostgreSQL ODBC driver from AUR on Arch Linux
|
||||||
|
#
|
||||||
|
- include_tasks: install_arch_odbc.yml
|
||||||
|
when: ansible_facts.os_family == 'Archlinux'
|
||||||
|
|
||||||
#
|
#
|
||||||
# Get pyodbc installed
|
# Get pyodbc installed
|
||||||
#
|
#
|
||||||
@@ -51,6 +56,11 @@
|
|||||||
dsn: "DRIVER={PostgreSQL Unicode};Server=localhost;Port=5432;Database=postgres;Uid={{ my_user }};Pwd={{ my_pass_decrypted }};UseUnicode=True"
|
dsn: "DRIVER={PostgreSQL Unicode};Server=localhost;Port=5432;Database=postgres;Uid={{ my_user }};Pwd={{ my_pass_decrypted }};UseUnicode=True"
|
||||||
when: ansible_facts.os_family == 'Debian'
|
when: ansible_facts.os_family == 'Debian'
|
||||||
|
|
||||||
|
- name: Changing DSN for Arch Linux
|
||||||
|
set_fact:
|
||||||
|
dsn: "DRIVER={/usr/lib/psqlodbcw.so};Server=localhost;Port=5432;Database=postgres;Uid={{ my_user }};Pwd={{ my_pass_decrypted }};UseUnicode=True"
|
||||||
|
when: ansible_facts.os_family == 'Archlinux'
|
||||||
|
|
||||||
#
|
#
|
||||||
# Name setup database
|
# Name setup database
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -100,6 +100,8 @@
|
|||||||
|
|
||||||
- name: Initialize postgres (Archlinux)
|
- name: Initialize postgres (Archlinux)
|
||||||
command: su - postgres -c "initdb --locale en_US.UTF-8 -D '/var/lib/postgres/data'"
|
command: su - postgres -c "initdb --locale en_US.UTF-8 -D '/var/lib/postgres/data'"
|
||||||
|
args:
|
||||||
|
creates: /var/lib/postgres/data/PG_VERSION
|
||||||
when: ansible_facts.os_family == "Archlinux"
|
when: ansible_facts.os_family == "Archlinux"
|
||||||
|
|
||||||
- name: Initialize postgres (Alpine)
|
- name: Initialize postgres (Alpine)
|
||||||
|
|||||||
Reference in New Issue
Block a user