Configure systems and deploy software by using Ansible.
python and pip installed. (python3 is preferred).
If you are using Windows, it is strongly recommended to use Windows Subsystem for Linux (WSL docs).
- install and configure common softwares like bash, vim, etc. (How-to)
- tested platforms:
- Ubuntu 18.04+
- CentOS 7.5
- tested platforms:
- install latest docker-ce
- tested platforms:
- Ubuntu 18.04+
- CentOS 7.5
- tested platforms:
- install shadowsocks-libev and v2ray-plugin
- tested platforms:
- Ubuntu 18.04+
- tested platforms:
git clone --recursive https://github.com/bingzhangdai/ansible-deploy.git
cd ansible-deploy
# sudo make env PYTHON=python3
sudo make evn
Modify hosts and put all remote servers in file hosts
.
host_or_ip_0
host_or_ip_1
Update vars under group_vars/all/*
. Change remote user name and password for variable ansible_user
and ansible_ssh_pass
in file group_vars/all/main.yml
for ssh login.
ansible_user: root
ansible_ssh_pass: root_passwd
Modify other vars as needed.
Use ansible-vault to encrypt password, if you want to check in your password.
make encrypt
If you see the warning [WARNING]: Ansible is being run in a world writable directory
, Export ANSIBLE_CONFIG
environmental variable.
export ANSIBLE_CONFIG=`pwd`/ansible.cfg
git ls-files | xargs dos2unix
Set up remote machines environment and update repository.
ansible-playbook bootstrap.yml -i hosts --tags "repo"
The playbook site.yml
contains all the tasks. But usually we want to skip one or more components. Just look at it and decide.
# install only shadowsocks-libev
ansible-playbook site.yml -i hosts --tags "shadowsocks-libev"
# install common packages but do not copy config files
ansible-playbook site.yml -i hosts --tags "common" --skip-tags "configuration"
ansible-playbook site.yml -i hosts --tags "docker-ce"
Ansible known issues
-
Synchronize with password authentication does not work with python 2:
[Errno 32] Broken pipe
.Workaround: using python3
-
Synchronize module doesn't work with vault
If you are using ansible-vault, then a workaround is adding argument
--extra-vars 'ansible_ssh_pass=your_passwd'
inansible-playbook
command