Skip to content

Configure systems and deploy software by using Ansible.

License

Notifications You must be signed in to change notification settings

bingzhangdai/ansible-deploy

Repository files navigation

Ansible deploy

Syntax Check

Configure systems and deploy software by using Ansible.

Prerequisites

python and pip installed. (python3 is preferred).

If you are using Windows, it is strongly recommended to use Windows Subsystem for Linux (WSL docs).

This playbook can

  • install and configure common softwares like bash, vim, etc. (How-to)
    • tested platforms:
      • Ubuntu 18.04+
      • CentOS 7.5
  • install latest docker-ce
    • tested platforms:
      • Ubuntu 18.04+
      • CentOS 7.5
  • install shadowsocks-libev and v2ray-plugin
    • tested platforms:
      • Ubuntu 18.04+

How to use

Clone and config environment

git clone --recursive https://github.com/bingzhangdai/ansible-deploy.git
cd ansible-deploy
# sudo make env PYTHON=python3
sudo make evn

Edit inventory (hosts)

Modify hosts and put all remote servers in file hosts.

host_or_ip_0
host_or_ip_1

Modify default group vars

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.

Encrypt password (optional)

Use ansible-vault to encrypt password, if you want to check in your password.

make encrypt

Windows control machine or WSL

Export ANSIBLE_CONFIG env

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

Change the line ending

git ls-files | xargs dos2unix

Bootstrap remote machines

Set up remote machines environment and update repository.

ansible-playbook bootstrap.yml -i hosts --tags "repo"

Use cases

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"

Install latest docker-ce

ansible-playbook site.yml -i hosts --tags "docker-ce"

FAQ

Known issues

Ansible known issues