나는 Vagrant로 시작한 가상 머신을 프로비저닝 할 때 Ansible을 사용하고 있습니다. 필자는 (선호하는) VMware 공급자와 VirtualBox를 모두 테스트에 사용했으며 각각 동일한 결과를 얻고 있습니다.Postgres 사용자 비밀번호를 설정하지 말 것
so
이라는 데이터베이스와 액세스 할 수있는 django
데이터베이스를 만들려면 다음 작업을 사용하고 있습니다. 그러나 데이터베이스 암호가 설정되지 않는 것처럼 보입니다. 내가 수동으로 설정하면 연결할 수 있습니다. 사전에 시도하면 항상 FATAL: password authentication failed for user "django"
이됩니다.
나는 아래의 위험한 구성의 관련 섹션과 디버그의 해당 섹션을 게시했습니다 (방해벽 구성에서는 ansible.verbose = "vvv"
).
# Create Prostgres DB
- hosts: all
sudo: True
sudo_user: postgres
vars:
dbname: so
dbuser: django
dbpassword: 4967bKzCegrPxVH4tGgQe6kFn232t7KiFDXfedVi
tasks:
- name: Ensure database exists
postgresql_db: name={{ dbname }}
- name: Ensure DB user has access to the DB
postgresql_user: db={{ dbname }} name={{ dbuser }} password={{ dbpassword }} priv=ALL state=present
# Leave user with ability to create databases. This prividge should be
# removed for production, but is required for running tests.
postgresql_user: name={{ dbuser }} role_attr_flags=NOSUPERUSER,CREATEDB
자세한 정보 출력 : 연결할 때 호스트 이름을 제공 할 필요가 있기 때문에
TASK: [Ensure DB user has access to the DB] ***********************************
<127.0.0.1> ESTABLISH CONNECTION FOR USER: vagrant
<127.0.0.1> EXEC ['ssh', '-tt', '-q', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/Users/danielsgroves/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=2222', '-o', 'IdentityFile=/Users/danielsgroves/.vagrant.d/insecure_private_key', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 'ConnectTimeout=10', '127.0.0.1', "/bin/sh -c 'mkdir -p /tmp/ansible-1387481596.93-132175356393082 && chmod a+rx /tmp/ansible-1387481596.93-132175356393082 && echo /tmp/ansible-1387481596.93-132175356393082'"]
<127.0.0.1> REMOTE_MODULE postgresql_user name=django role_attr_flags=NOSUPERUSER,CREATEDB
<127.0.0.1> PUT /var/folders/2j/n8ng8fdd5gj125w5zswg9kj00000gn/T/tmpvnrb37 TO /tmp/ansible-1387481596.93-132175356393082/postgresql_user
<127.0.0.1> EXEC ['ssh', '-tt', '-q', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/Users/danielsgroves/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=2222', '-o', 'IdentityFile=/Users/danielsgroves/.vagrant.d/insecure_private_key', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 'ConnectTimeout=10', '127.0.0.1', "/bin/sh -c 'chmod a+r /tmp/ansible-1387481596.93-132175356393082/postgresql_user'"]
<127.0.0.1> EXEC ['ssh', '-tt', '-q', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/Users/danielsgroves/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=2222', '-o', 'IdentityFile=/Users/danielsgroves/.vagrant.d/insecure_private_key', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 'ConnectTimeout=10', '127.0.0.1', '/bin/sh -c \'sudo -k && sudo -H -S -p "[sudo via ansible, key=isnxrvycjudgazbgyciehbcpiiswfczx] password: " -u postgres /bin/sh -c \'"\'"\'echo SUDO-SUCCESS-isnxrvycjudgazbgyciehbcpiiswfczx; /usr/bin/python /tmp/ansible-1387481596.93-132175356393082/postgresql_user\'"\'"\'\'']
<127.0.0.1> EXEC ['ssh', '-tt', '-q', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/Users/danielsgroves/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=2222', '-o', 'IdentityFile=/Users/danielsgroves/.vagrant.d/insecure_private_key', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 'ConnectTimeout=10', '127.0.0.1', "/bin/sh -c 'rm -rf /tmp/ansible-1387481596.93-132175356393082/ >/dev/null 2>&1'"]
ok: [server] => {"changed": false, "user": "django"}
흥미롭게도이 기능은 물리적 인 상자에서 작동하는 것으로 보입니다. 다만, Vagrant VM에서는 작동하지 않습니다. 잠시 나마 더 조사 할거야. –
혹시 이것을 알아 냈습니까? – jrg
불행히도 아닙니다. 그러나 동일한 명령은 Digital Ocean에서 호스팅되는 제작 상자에 사용되는 다른 공급 업체에서 작동합니다. –