0
我正在使用Ansible設置VPS。這是我的build_server YAML文件:Ansible設置Rails VPS
---
- hosts: do_server
vars_files:
- vars/defaults.yml
sudo: yes
remote_user: root
roles:
- { role: create-deploy-user, tags: ['create-deploy-user'] }
- hosts: do_server
vars_files:
- vars/defaults.yml
remote_user: "{{ deploy }}"
gather_facts: no
roles:
### Server provisioning roles:
- { role: linux-prereqs, tags: ['linux-prereqs'] }
- { role: postgresql, tags: ['postgresql'] }
- { role: rbenv, tags: ['rbenv'] }
- { role: ruby, tags: ['ruby'] }
- { role: nginx-passenger, tags: ['nginx-passenger'] }
### Site specific roles:
- { role: prepare_site, tags: ['prepare_site'] }
它一起去的文件,直到它得到了Linux-prereqs作用。在這裏我得到一個錯誤:「失蹤成爲密碼」。
我有點困惑,因爲我沒有爲我的「部署」用戶設置密碼,並且將我的SSH密鑰添加到它作爲創建用戶的一部分,因此肯定我應該已經被授權?我的創建部署用戶任務是:
- name: create {{ deploy }} user
user:
name: "{{ deploy }}"
comment: "deploy user"
generate_ssh_key: yes
state: present
shell: /bin/bash
- name: authorize my SSH key to access {{ deploy }}
authorized_key:
key: "{{ lookup('file', '/Users/neil/.ssh/id_rsa.pub') }}"
user: "{{ deploy }}"
state: present
- name: add {{ deploy }} to sudoers
lineinfile: "dest=/etc/sudoers state=present line='{{ deploy }} ALL=(ALL:ALL) ALL'"
- name: create www-data group
group:
name: www-data
state: present
任何想法?