Ansible从以下代码请求sudo密码,它尝试创建一个新的postgres用户.
错误信息:
致命:[xxx.xxx.xxx.xxx] =>缺少sudo密码
main.yml
- name: 'Provision a PostgreSQL server'
hosts: "dbservers"
sudo: yes
sudo_user: postgres
roles:
- postgres
Run Code Online (Sandbox Code Playgroud)
create_db.yml
- name: Make sure the PostgreSQL users are present
postgresql_user: name=rails password=secret role_attr_flags=CREATEDB,NOSUPERUSER
sudo_user: postgres
sudo: yes
Run Code Online (Sandbox Code Playgroud)
用于登录此计算机的remote_user 是非root用户,没有密码,只能使用密钥身份验证登录.
对于用户postgres,此帐户也没有密码,因为刚刚安装了数据库.
由于我以非 root用户身份登录,因此当切换到postgress帐户以创建数据库用户时,它会询问密码.但是如果从root帐户切换到postgres,则不需要密码.所以,我想知道是否有办法切换到root,然后切换到用户postgres.
注意:root帐户没有公钥,没有密码,也无法从SSH登录.
ansible ×1