Ansible: Falha no manual básico do PostgreSQL

Criado em 24 mar. 2016  ·  3Comentários  ·  Fonte: ansible/ansible

TIPO DE PROBLEMA
  • Relatório de erro
    VERSÃO ANSIBLE
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/

CONFIGURAÇÃO

Nada, que eu saiba. Vou atualizar isso se eu aprender o contrário.

SO / AMBIENTE
RESUMO

Estou no IRC há cerca de uma hora tentando resolver por que estou recebendo um erro.

Não há mais nada no meu manual além de nomes de variáveis. Isto está em um recipiente limpo e fresco. Eu posso psql -U postgres bem, então isso tem que ser algo com ansible.

PASSOS PARA REPRODUZIR
 - 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 ESPERADOS

Para que ele acesse o banco de dados e crie um usuário.

RESULTADOS REAIS
<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

Comentários muito úteis

Para a posteridade, se você estiver criando um novo banco de dados ou um novo usuário, você deve se tornar o usuário postgres . Eu estava tentando fazer isso como root e continuei recebendo o erro. Exemplo de trabalho abaixo.

  - 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 comentários

Desculpe ter perdido seu tempo lendo isso. faltou become: yes

Para a posteridade, se você estiver criando um novo banco de dados ou um novo usuário, você deve se tornar o usuário postgres . Eu estava tentando fazer isso como root e continuei recebendo o erro. Exemplo de trabalho abaixo.

  - 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

Estou usando o Ansible 2.6.2 e ainda não funciona para mim

Esta página foi útil?
0 / 5 - 0 avaliações