Chef server 12 reconfiguration is not working on Ubuntu 14.04 - postgresql

I'm trying to install a Chef server on an Ubuntu 14.04 box. I've downloaded the .deb file from the site and installed with sudo dpkg -i chef-server-core_12.0.8-1_amd64.deb but when I do sudo chef-server-ctl reconfigure all goes well until it reaches the postgresql part:
Running handlers:
[2015-05-03T23:16:07-04:00] ERROR: Running exception handlers
Running handlers complete
[2015-05-03T23:16:07-04:00] ERROR: Exception handlers complete
[2015-05-03T23:16:07-04:00] FATAL: Stacktrace dumped to /opt/opscode/embedded/cookbooks/cache/chef-stacktrace.out
Chef Client failed. 44 resources updated in 198.107797872 seconds
[2015-05-03T23:16:08-04:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: private-chef_pg_database[opscode-pgsql] (private-chef::postgresql line 127) had an error: Mixlib::ShellOut::ShellCommandFailed: execute[create_database_opscode-pgsql] (/opt/opscode/embedded/cookbooks/cache/cookbooks/private-chef/providers/pg_database.rb line 13) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of createdb --template template0 --encoding UTF-8 opscode-pgsql ----
STDOUT:
STDERR: createdb: could not connect to database template1: FATAL: role "opscode-pgsql" does not exist
---- End output of createdb --template template0 --encoding UTF-8 opscode-pgsql ----
Ran createdb --template template0 --encoding UTF-8 opscode-pgsql returned 1
Am I missing any step? The installation instruction does not say anything about any other middle task to perform.
Thank you very much for any help you can give me.

Saw exact same error installing chef-server-core-12.0.8-1.el6.x86_64.rpm on RHEL6.6. Had gone through every pre-req step listed at https://docs.chef.io/install_server_pre.html ... finally chalked it up to having multiple versions of Postgres on the system.
Attempted the same install and reconfigure command (chef-server-ctl reconfigure) on a system without Postgres installed and had success.
HTH.

Cannot reproduce your problem. The installation of chef server 12.0.8-1 worked fine on my kitchen/vagrant setup
Example
├── Berksfile
├── .kitchen.yml
├── roles
   └── chef-server.json
Berksfile
source "https://supermarket.chef.io"
cookbook "chef-server"
kitchen.yml
---
driver:
name: vagrant
provisioner:
name: chef_zero
platforms:
- name: ubuntu-14.04
driver:
network:
- ["private_network", {ip: "192.168.38.34"}]
customize:
memory: 4096
suites:
- name: default
run_list:
- role[chef-server]
attributes:
roles/chef-server.json
{
"name": "chef-server",
"description": "Chef server",
"run_list": [
"recipe[chef-server]"
]
}

Related

Flyway not able to find role with postgres docker

I am trying to run my first flyway example using docker postgres image but getting the following error:
INFO: Flyway Community Edition 6.4.2 by Redgate
Exception in thread "main" org.flywaydb.core.internal.exception.FlywaySqlException:
Unable to obtain connection from database (jdbc:postgresql://localhost/flyway-service) for user 'flyway-service': FATAL: role "flyway-service" does not exist
-------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL State : 28000
Error Code : 0
Message : FATAL: role "flyway-service" does not exist
at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:65)
at org.flywaydb.core.internal.jdbc.JdbcConnectionFactory.<init>(JdbcConnectionFactory.java:80)
I looked up into the docker container and can see that the user role flyway-service is created as part of the docker-compose execution:
$ docker exec -it flywayexample_postgres_1 bash
root#b2037e382112:/# psql -U flyway-service;
psql (12.2 (Debian 12.2-2.pgdg100+1))
Type "help" for help.
flyway-service=# \du;
List of roles
Role name | Attributes | Member of
----------------+------------------------------------------------------------+-----------
flyway-service | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
flyway-service=#
Main class is:
public static void main( String[] args ) {
var flyway = Flyway.configure().schemas("flyway_test_schema")
.dataSource("jdbc:postgresql://localhost/flyway-service", "flyway-service",
"password")
.load()
.migrate();
System.out.println( "Flyway example's hello world!" );
}
}
The migration called src/main/resources/db/migration/V1__Create_person_table.sql:
create table PERSON (
ID int not null,
NAME varchar(100) not null
);
Docker-compose yml file:
version: "3.8"
services:
postgres:
image: postgres:12.2
ports: ["5432:5432"]
environment:
- POSTGRES_PASSWORD=password
- POSTGRES_USER=flyway-service
I am running this code on MAC OSX. I assume, I am missing something obvious here, but not sure what! Any pointers would be appreciated.
Finally managed to figure out the issue with the help of a friend! The problem was not with the attached code but with a postgres daemon process running on the same port 5432 by an old Postgres installation.
I found the complete uninstallation procedure here. After removing the additional daemon process got only one port listening.
a$ lsof -n -i4TCP:5432
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
com.docke 654 root 50u IPv6 0x7ae1b5f8fbcf1cb 0t0 TCP *:postgresql (LISTEN)

ERROR could not access file "$libdir/repmgr_funcs" No such file or directory

I follow this link to create master slave replication on Ubuntu postgresql server.
My Configuration of repmgr and postgresql are:
Postgresql 9.5-: /opt/PostgreSQL/9.5/
repmgr-: /usr/lib/postgresql/9.5/bin/repmgr
repmgr.conf -: /etc/rep.conf
pg_config --pkglibdir => /usr/lib/postgresql/9.5/lib
ls /usr/lib/postgresql/9.5/lib | grep repmgr_funcs => repmgr_funcs.so
I am getting ERROR-: unable to create the function
repmgr_update_last_updated: ERROR: could not access file "$libdir/repmgr_funcs": No such file or directory
ERROR: Unable to create repmgr schema - see preceding error message(s); aborting
If you are using repmgr ver. 4 and above then you need to change in postgresql.conf
From shared_preload_libraries = 'repmgr_funcs'
To shared_preload_libraries = 'repmgr'
Below are their upgrade notes
The repmgr shared library has been renamed from repmgr_funcs to
repmgr, meaning shared_preload_libraries in postgresql.conf needs to
be updated to the new name: shared_preload_libraries = 'repmgr'

after lein ring server, I get error PSQLException no password was provided

I am naive in Postgres and clojure
I wanted to run this https://gitlab.com/dzaporozhets/clojure-picture-gallery
Install
git clone https://gitlab.com/clojure-code-examples/picture-gallery.git
cd picture-gallery
# Install dependencies
lein deps
# Create database
psql -c 'CREATE DATABASE gallery TEMPLATE template0'
Running
To start a web server for the application, run:
lein ring server
this is process I have to do.
1)) I had to git clone but git clone have not worked. they want to let me type id, password. like this:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\jiji>git clone https://gitlab.com/clojure-code-examples/picture-gallery
.git
Cloning into 'picture-gallery'...
Username for 'https://gitlab.com': ji
Password for 'https://ji#gitlab.com':
fatal: Authentication failed for 'https://gitlab.com/clojure-code-examples/pictu
re-gallery.git/'
C:\Users\jiji>
anyway I downloaded source from web and unzip this file
2) I have problem when I write psql -c 'CREATE DATABASE gallery TEMPLATE template0'. I use Windows 7. Though I installed postgresql, 'psql' instruction have not worked in cmd window. I don't know how I can use 'psql' instruction in window. anyway I make gallery database like this
3) and I write lein ring server in cmd window
but I got error like this:
C:\Users\jiji\clojureproject\clojure-picture-gallery-master>lein ring server
picture-gallery is starting
Exception in thread "main" org.postgresql.util.PSQLException: The server request
ed password-based authentication, but no password was provided., compiling:(C:\U
sers\jiji\AppData\Local\Temp\form-init366034846235691962.clj:1:105)
at clojure.lang.Compiler.load(Compiler.java:7142)
at clojure.lang.Compiler.loadFile(Compiler.java:7086)
at clojure.main$load_script.invoke(main.clj:274)
at clojure.main$init_opt.invoke(main.clj:279)
at clojure.main$initialize.invoke(main.clj:307)
at clojure.main$null_opt.invoke(main.clj:342)
at clojure.main$main.doInvoke(main.clj:420)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:383)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
Caused by: org.postgresql.util.PSQLException: The server requested password-base
d authentication, but no password was provided.
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(Connect
ionFactoryImpl.java:473)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(Conne
ctionFactoryImpl.java:203)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactor
y.java:65)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Conn
ection.java:146)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Conn
ection.java:35)
at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gC
onnection.java:22)
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Conn
ection.java:47)
at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:30)
at org.postgresql.Driver.makeConnection(Driver.java:414)
at org.postgresql.Driver.connect(Driver.java:282)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at clojure.java.jdbc$get_connection.invoke(jdbc.clj:177)
at clojure.java.jdbc$get_connection.invoke(jdbc.clj:161)
at clojure.java.jdbc$get_connection.invoke(jdbc.clj:164)
at clojure.java.jdbc$with_connection_STAR_.invoke(jdbc.clj:300)
at picture_gallery.models.schema$table_exists_QMARK_.invoke(schema.clj:2
8)
at picture_gallery.models.schema$migrate.invoke(schema.clj:35)
at picture_gallery.handler$init.invoke(handler.clj:18)
at clojure.lang.Var.invoke(Var.java:375)
at ring.server.standalone$serve.doInvoke(standalone.clj:93)
at clojure.lang.RestFn.invoke(RestFn.java:423)
at ring.server.leiningen$serve.invoke(leiningen.clj:20)
at user$eval6633.invoke(form-init366034846235691962.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6703)
at clojure.lang.Compiler.eval(Compiler.java:6693)
at clojure.lang.Compiler.load(Compiler.java:7130)
... 11 more
Subprocess failed
C:\Users\jiji\clojureproject\clojure-picture-gallery-master>
I guess it is password problem. but I don't know what it means
in short I have three question about 1)),2)),3)) why they are not worked?
answerto question 3)
take a look at /src/picture_gallery/models/db.clj here https://gitlab.com/dzaporozhets/clojure-picture-gallery/blob/master/src/picture_gallery/models/db.clj#L4
either set you DATABASE_URL environment variable to contain valid postgres connection url or just use
(def db (or (System/getenv "DATABASE_URL")
"postgresql://user:password#localhost:5432/gallery"))
replace user and password before #localhost with your postgres's user and password

Alembic / Flask-migrate migration on Heroku runs but does not create tables

I am attempting to deploy a Flask app to Heroku. I have pushed to Heroku and can access my login page but any call to the db gives an OperationalError:
2014-01-29T12:12:31.801772+00:00 app[web.1]: OperationalError: (OperationalError) no such table: projects_project u'SELECT
Using Flask-migrate I can successfully run local migrations and upgrades:
INFO [alembic.migration] Context impl PostgresqlImpl.
INFO [alembic.migration] Will assume transactional DDL.
INFO [alembic.migration] Running upgrade None -> 4b56d58e1d4c, empty message
When I try to upgrade on Heroku using heroku run python manage.py db upgrade the upgrade appears to happen, but the Context impl. is now SQLite?:
(dev01)Toms-MacBook-Pro:dev01 kt$ heroku run python manage.py db upgrade
Running `python manage.py db upgrade` attached to terminal... up, run.9069
INFO [alembic.migration] Context impl SQLiteImpl.
INFO [alembic.migration] Will assume non-transactional DDL.
INFO [alembic.migration] Running upgrade None -> 4b56d58e1d4c, empty message
Running Heroku pg:info gives:
=== HEROKU_POSTGRESQL_PINK_URL (DATABASE_URL)
Plan: Dev
Status: available
Connections: 0
PG Version: 9.3.2
Created: 2014-01-27 18:55 UTC
Data Size: 6.4 MB
Tables: 0
Rows: 0/10000 (In compliance)
Fork/Follow: Unsupported
Rollback: Unsupported
The relevant logs for the Heroku upgrade are:
2014-01-29T12:55:40.112436+00:00 heroku[api]: Starting process with command `python manage.py db upgrade` by kt#gmail.com
2014-01-29T12:55:44.638957+00:00 heroku[run.9069]: Awaiting client
2014-01-29T12:55:44.667692+00:00 heroku[run.9069]: Starting process with command `python manage.py db upgrade`
2014-01-29T12:55:44.836337+00:00 heroku[run.9069]: State changed from starting to up
2014-01-29T12:55:46.643857+00:00 heroku[run.9069]: Process exited with status 0
2014-01-29T12:55:46.656134+00:00 heroku[run.9069]: State changed from up to complete
Also, heroku config gives me:
(dev01)Toms-MacBook-Pro:dev01 kt$ heroku config
=== myapp Config Vars
DATABASE_URL: postgres://xxx.compute-1.amazonaws.com:5432/da0jtkatk6057v
HEROKU_POSTGRESQL_PINK_URL: postgres://xxx.compute-1.amazonaws.com:5432/da0jtkatk6057v
where [xxx == xxx]
How is the Context impl. set? Apart from this obvious difference between working local and heroku, I can't work out what's happening or how I should debug. Thanks.
The URL for the database is taken from the SQLALCHEMY_DATABASE_URI configuration in your Flask app instance. This happens in the env.py configuration for Alembic that was created in the migrations folder.
Are you storing the value of os.environ['DATABASE_URL'] in the configuration before you hand over control to Flask-Migrate and Alembic? It seems you have a default SQLite based database that never gets overwritten with the real one provided by Heroku.

Ansible postgresql_db task fails after a very long pause

The following ansible task (in a vagrant VM) fails :
- name: ensure database is created
postgresql_db: name={{dbname}}
sudo_user: postgres
the task pauses for a few minutes before failing
the vagrant VM is a centos6.5.1,
the tasks output is :
TASK: [postgresql | ensure database is created] *******************************
fatal: [192.168.78.6] => failed to parse:
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo via ansible, key=glxzviadepqkwddapvjheeuillbdakly] password:
FATAL: all hosts have already failed -- aborting
I have verified that postgres is prooperly installed
by doing vagrant ssh and connecting vial psql.
I also validated that I can do a "sudo su postgres" within the VM ...
======== update
It looks like the problem is the sudo_user: postgres, because removing the
above postgres tasks and replacing with this one causes the same problem :
- name: say hello from postgress
command: echo "hello"
sudo_user: postgres
the output is exactly the same as above, so it's really a problem of
ansible doing a sudo_user on centos6.5
one interesting observation, although I can do "sudo su postgres" from
inside the vm
when I call "psql" (as the postgres user) I get the message :
could not change directory to "/home/vagrant": Permission denied
but the psql shell still starts successfully
======== conclusion
Problem was fixed by changing to a stock centos box,
lesson learned : when using ansible/vagrant, only use stock OS images...
I am using the wait for host:
- local_action: wait_for port=22 host="{{PosgresHost}}" search_regex=OpenSSH delay=1 timeout=60
ignore_errors: yes
PS:
I think you should use gather_facts: False and do setup after ssh is up.
Example main.yml:
---
- name: Setup
hosts: all
#connection: local
user: root
gather_facts: False
roles:
- main
Example roles/main/tasks/main.yml
- debug: msg="System {{ inventory_hostname }} "
- local_action: wait_for port=22 host="{{ inventory_hostname}}" search_regex=OpenSSH delay=1 timeout=60
ignore_errors: yes
- action: setup
ansible-playbook -i 127.0.0.1, main.yml
PLAY [Setup] ******************************************************************
TASK: [main | debug msg="System {{ inventory_hostname }} "] *******************
ok: [127.0.0.1] => {
"msg": "System 127.0.0.1 "
}
TASK: [main | wait_for port=22 host="{{ inventory_hostname}}" search_regex=OpenSSH delay=1 timeout=60] ***
ok: [127.0.0.1 -> 127.0.0.1]
PLAY RECAP ********************************************************************
127.0.0.1 : ok=2 changed=0 unreachable=0 failed=0