Closed vladp closed 4 years ago
@nysan , do you have Fedora experience?
is there a working task/playbook that somebody could share where this roles on any of the redhat-family systems (redhat, fedora, centos)
I am not able to resolve the above error despite my best effort
despite my best effort, this is a problem with that I cannot seem to resolve. I suspect this will be a problem on RedHat derived setups (fedora, redhat, centos). Reason why it does not show up when this role is run on Debian-derived distros -- is because, for those a different cluster initialization method is used.
I also do not think that the problem is with this role, instead this looks like a problem with Postgres's initdb. This role correctly sets the 'become' user to be postgres administrator (which by default is postgres).
Even if ansible logs in as 'postgres' user, initdb still thinks that the user trying to run initdb is root
I even wrote a simple task with 'command' module to just call initdb -- and it fails with the same error message: initdb: cannot be run as root
I can avoid this error if I tell this role to not initialize the cluster directory (and instead, I would have to login to each PG host and do it manually).
So to avoid the error do:
postgresql_cluster_reset: false
When setting variables for the ANSX.postgresql role
I just tested on my fedora 30 with the test playbook And it worked... For info, the role version is v1.11.1
Just a quick update. Again , I do not think there is any problem with this role, so will close the issue.
I think I am running into an ansible issue
https://github.com/ansible/ansible/issues/38129
Because I include role that underneath uses this role, via include_role.
And that way of including roles, underneath
somehow makes ansible ignore the
become: yes
become_user: 'postgres'
in configure.yml (lines around 107) that are executed for Redhat systems only.
So the reasons why others are not running into this is because most are probably not including roles with include_role
The error still on CentOS8
ans/roles/ANXS.postgresql/tasks/configure.yml:102
fatal: [primarynode__pgdb]: FAILED! => {"changed": true, "cmd": ["/usr/pgsql-12/bin/initdb", "-D", "/var/lib/pgsql/12/main", "--locale=en_US.UTF-8", "--encoding=UTF-8"], "delta": "0:00:00.066498", "end": "2020-05-30 01:49:55.765010", "msg": "non-zero return code", "rc": 1, "start": "2020-05-30 01:49:55.698512", "stderr": "initdb: error: cannot be run as root\nPlease log in (using, e.g., \"su\") as the (unprivileged) user that will\nown the server process.", "stderr_lines": ["initdb: error: cannot be run as root", "Please log in (using, e.g., \"su\") as the (unprivileged) user that will", "own the server process."], "stdout": "", "stdout_lines": []}
The target host was initialized by using Centos8 distro https://app.vagrantup.com/generic/boxes/centos8 version 3.0.6
The postgres distro was installed manually using:
dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
dnf -qy module disable postgresql
dnf install postgresql12 postgresql12-server
(these are steps prescribed in https://www.postgresql.org/download/linux/redhat/ )
this issue is not due the code in this role
Cannot figure out what I am doing wrong, appreciate, in advance, any help/pointers.
Setup:
target host Running Fedora 30 (within Vagrant: config.vm.box = "fedora/30-cloud-base" ) ANXS from git repo (not from galaxy) ansible 2.7 python is python3 not using mitogen
I checked the roles, code and in configure.yml it sets the become_user to postgres_service_user , which is itself set to postgres_admin_user..
that seems to be correct. I do not know how to debug if become is indeed executed. But the code for ansible_os_family=="Redhat" seems to be doing the right thing.
Role parameters