Ansible: El libro de jugadas básico de PostgreSQL falla

Creado en 24 mar. 2016  ·  3Comentarios  ·  Fuente: ansible/ansible

TIPO DE PROBLEMA
  • Informe de error
    VERSIÓN ENSIBLE
Package: ansible
Status: install ok installed
Priority: optional
Section: admin
Installed-Size: 7157
Maintainer: Ansible, Inc. <[email protected]>
Architecture: all
Version: 2.0.0.2-1ppa~trusty
Depends: python, python-support (>= 0.90), python-jinja2, python-yaml, python-paramiko, python-httplib2, python-six, python-crypto (>= 2.6), python-setuptools, sshpass
Conffiles:
 /etc/ansible/hosts 1564b951dc7c8511c6f9ee842653c541
 /etc/ansible/ansible.cfg 248f57c4cb0f11fe8fd5f39b12ac8205
Description: A radically simple IT automation platform
 A radically simple IT automation platform that makes your applications and
 systems easier to deploy. Avoid writing scripts or custom code to deploy and
 update your applications— automate in a language that approaches plain English,
 using SSH, with no agents to install on remote systems.
Homepage: http://ansible.github.com/

CONFIGURACIÓN

Nada, que yo sepa. Actualizaré esto si aprendo lo contrario.

SO / MEDIO AMBIENTE
RESUMEN

He estado en IRC durante aproximadamente una hora tratando de resolver por qué recibo un error.

No hay nada más en mi libro de jugadas aparte de los nombres de variables. Esto está en un recipiente limpio y fresco. Puedo psql -U postgres bien, así que esto tiene que ser algo con ansible.

PASOS PARA REPRODUCIR
 - name: Install PostgreSQL and related packages
   apt: name={{ item }} state=present update_cache=yes
   with_items:
      - postgresql
      - postgresql-contrib
      - python-psycopg2

 - name: Create new database user
   become_user: postgres
   postgresql_user: name=apples role_attr_flags=SUPERUSER,CREATEROLE,CREATEDB,REPLICATION

RESULTADOS PREVISTOS

Para que acceda a la base de datos y cree un usuario.

RESULTADOS ACTUALES
<postgres-dev.domain.com> ESTABLISH SSH CONNECTION FOR USER: root
<postgres-dev.domain.com> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/tmp/ansible-ssh-%h-%p-%r postgres-dev.domain.com 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python'
fatal: [postgres-dev.domain.com]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"db": "", "encrypted": false, "expires": null, "fail_on_user": true, "login_host": "", "login_password": "", "login_unix_socket": "", "login_user": "postgres", "name": "rooted", "no_password_changes": false, "password": null, "port": "5432", "priv": null, "role_attr_flags": "SUPERUSER,CREATEROLE,CREATEDB,REPLICATION", "state": "present", "user": "rooted"}, "module_name": "postgresql_user"}, "msg": "unable to connect to database: FATAL:  Peer authentication failed for user \"postgres\"\n"}
postgresql

Comentario más útil

Para la posteridad, si está creando una nueva base de datos o un nuevo usuario, debe convertirse en el usuario postgres . Estaba tratando de hacer esto como root y seguía recibiendo el error. Ejemplo de trabajo a continuación.

  - name: make events database
    postgresql_db:
      name: events
    become: true
    become_user: postgres

  - name: make www-data postgresql user
    postgresql_user:
      db: events
      name: www-data
      password: "{{ psql_password }}"
      priv: ALL
    become: true
    become_user: postgres

Todos 3 comentarios

Lamento haberte hecho perder el tiempo al tener que leer esto. me faltaba become: yes

Para la posteridad, si está creando una nueva base de datos o un nuevo usuario, debe convertirse en el usuario postgres . Estaba tratando de hacer esto como root y seguía recibiendo el error. Ejemplo de trabajo a continuación.

  - name: make events database
    postgresql_db:
      name: events
    become: true
    become_user: postgres

  - name: make www-data postgresql user
    postgresql_user:
      db: events
      name: www-data
      password: "{{ psql_password }}"
      priv: ALL
    become: true
    become_user: postgres

Estoy usando Ansible 2.6.2 y aun no me funciona

¿Fue útil esta página
0 / 5 - 0 calificaciones