1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-05-03 08:52:55 +00:00

[PR #11944/c7be9e4d backport][stable-12] odbc: add Arch Linux support via AUR psqlodbc (#11963)

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

(cherry picked from commit c7be9e4d5b)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2026-05-01 21:49:56 +02:00 committed by GitHub
parent 22deae25c9
commit 365e02d10c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 85 additions and 1 deletions

View 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

View file

@ -5,4 +5,5 @@
dependencies:
- setup_pkg_mgr
- setup_remote_tmp_dir
- setup_postgresql_db

View 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

View file

@ -12,7 +12,6 @@
msg: "{{ ansible_facts.os_family }} / {{ ansible_facts.distribution }} / {{ ansible_facts.distribution_major_version }}"
- 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)!
block:
@ -23,6 +22,12 @@
- include_tasks: no_pyodbc.yml
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
#
@ -51,6 +56,11 @@
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'
- 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
#

View file

@ -100,6 +100,8 @@
- name: Initialize postgres (Archlinux)
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"
- name: Initialize postgres (Alpine)