Modify user-management function

pull/47/head
jack 8 years ago
parent f6c1309aac
commit 917b7d6138

@ -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

@ -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

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

@ -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

@ -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

52
run

@ -1,21 +1,35 @@
#!/bin/sh
echo -n "
What provider would you like to use?
1. DigitalOcean
2. Amazon EC2
3. Local installation (non-cloud or a server already deployed)
Enter the number of your desired provider
: "
read N
case "$N" in
1) CLOUD="digitalocean" ;;
2) CLOUD="ec2" ;;
3) CLOUD="non-cloud" ;;
*) exit 1 ;;
esac
ansible-playbook deploy.yml -e "provider=${CLOUD}"
algo_provisioning () {
echo -n "
What provider would you like to use?
1. DigitalOcean
2. Amazon EC2
3. Local installation (non-cloud or a server already deployed)
Enter the number of your desired provider
: "
read N
case "$N" in
1) CLOUD="digitalocean" ;;
2) CLOUD="ec2" ;;
3) CLOUD="non-cloud" ;;
*) exit 1 ;;
esac
ansible-playbook deploy.yml -e "provider=${CLOUD}"
}
user_management () {
ansible-playbook users.yml
}
case "$1" in
users) user_management ;;
*) algo_provisioning ;;
esac

@ -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:

Loading…
Cancel
Save