Modify user-management function

This commit is contained in:
jack 2016-08-11 23:54:29 +03:00
parent f6c1309aac
commit 917b7d6138
7 changed files with 64 additions and 32 deletions

View file

@ -35,11 +35,12 @@ Algo (short for "Al Gore", the **V**ice **P**resident of **N**etworks everywhere
### Initial Deployment
To install the dependencies on OS X:
To install the dependencies on OS X or Linux:
```
sudo easy_install pip
sudo pip install ansible dopy==0.3.5
sudo pip install boto
```
There are two available cloud providers:
@ -59,17 +60,12 @@ When the process is done, you can find `.mobileconfig` files and certificates in
### User Management
When the deploy proccess is done a new server will be placed in the local inventory file `inventory_users`. If you want to add or delete users, update the `users` list in `config.cfg` and run the playbook `users.yml`. This command will update users on any servers in the file `inventory_users`.
If you want to add or delete users, update the `users` list in `config.cfg` and run the command:
```
ansible-playbook users.yml --user=root -i inventory_users
./run users
```
Note: For EC2 users, Algo does NOT use EC2 dynamic inventory for user management. Please continue to use users.yml playbook as described below. This may be subject to change in the future.
```
ansible-playbook users.yml --user=ubuntu -i inventory_users
```
## FAQ

View file

@ -108,6 +108,7 @@
- name: Wait for SSH to become available
local_action: "wait_for port=22 host={{ inventory_hostname }} timeout=320"
become: false
roles:
- common

View file

@ -1,2 +0,0 @@
[user-management]
52.59.88.212

View file

@ -9,7 +9,7 @@
private: no
- name: "server_user"
prompt: "What user should we use?:\n"
prompt: "What user should we use to login on the server?:\n"
default: "root"
private: no

View file

@ -136,9 +136,5 @@
- name: Fetch server CA certificate
fetch: src=/{{ easyrsa_dir }}/easyrsa3/pki/ca.crt dest=configs/{{ server_name }}_ca.crt flat=yes
- name: Add server to the inventory file
local_action: lineinfile dest=inventory_users line="{{ inventory_hostname }}" insertafter='\[user-management\]\n' state=present
become: false
notify:
- congrats

14
run
View file

@ -1,5 +1,6 @@
#!/bin/sh
algo_provisioning () {
echo -n "
What provider would you like to use?
1. DigitalOcean
@ -19,3 +20,16 @@ case "$N" in
esac
ansible-playbook deploy.yml -e "provider=${CLOUD}"
}
user_management () {
ansible-playbook users.yml
}
case "$1" in
users) user_management ;;
*) algo_provisioning ;;
esac

View file

@ -1,7 +1,34 @@
---
- hosts: localhost
gather_facts: False
vars_files:
- config.cfg
vars_prompt:
- name: "server_ip"
prompt: "\nEnter IP address of your server:\n"
private: no
- name: "server_user"
prompt: "What user should we use to login on the server?:\n"
default: "root"
private: no
tasks:
- name: Add the server to the vpn-host group
add_host:
hostname: "{{ server_ip }}"
groupname: vpn-host
ansible_ssh_user: "{{ server_user }}"
ansible_python_interpreter: "/usr/bin/python2.7"
- name: Wait for SSH to become available
local_action: "wait_for port=22 host={{ server_ip }} timeout=320"
become: false
- name: User management
hosts: user-management
hosts: vpn-host
gather_facts: false
become: true
vars_files: