dnf - install postgresql fom postgresql.org yum repos

450 views
Skip to first unread message

dulh...@mailbox.org

unread,
Mar 20, 2022, 5:30:48 AM3/20/22
to ansible...@googlegroups.com
I want to install PostgreSQL & barman with Ansible from the PostgreSQL.org repositories on an almalinux lxd container.

- name: "install PostgreSQL-14 & barman @rhel via postgresql.org repos"
  hosts: barman-220320
  tasks:
    - name: "install postgresql-14 & barman"
      dnf:
        name: "{{ item }}"
        enablerepo: https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
        state: latest
      loop:
        - postgresql14-server
        - barman
      become: true

as none of the 2 package can be installed it seems my enablerepo is not working though:
failed: [barman-220320] (item=postgresql14-server) => changed=false
  ansible_loop_var: item
  failures:
  - No package postgresql14-server available.
  item: postgresql14-server
  msg: Failed to install some of the specified packages
  rc: 1
  results: []
failed: [barman-220320] (item=barman) => changed=false
  ansible_loop_var: item
  failures:
  - No package barman available.
  item: barman
  msg: Failed to install some of the specified packages
  rc: 1
  results: []

I adapted it from https://www.postgresql.org/download/linux/redhat/

can anybody advise where I am falling short in this?

Abhijeet Kasurde

unread,
Mar 20, 2022, 7:24:01 AM3/20/22
to ansible...@googlegroups.com
Hi,

You are specifying RPM url location in `enablerepo`, whereas `enablerepo` expects the name of the repoids. You may need to install the Postgresql rpm first and then use the repo in a subsequent task.

    - name: Install Postgresql official repo
      dnf:
        name: https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
        state: latest
        disable_gpg_check: yes

    - name: Install packages
      dnf:
        name: "{{ item }}"
        state: "present"
      with_items:
        - postgresql
        - postgresql-server

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/4547acee-34ee-6697-87f3-11a6e24b4bee%40mailbox.org.


--
Thanks,
Abhijeet Kasurde
Reply all
Reply to author
Forward
0 new messages