Docker Daemon on Ansible

From Knowledge Center
Jump to: navigation, search

Install Ansible:

$ pip install ansible

hosts

[docker-cluster]
51.15.241.218

docker.yml

---
- hosts: all
  tasks:
  - name:    Install prerequisites
    apt:     name={{item}} update_cache=yes
    with_items:
     - apt-transport-https
     - ca-certificates
     - curl
     - software-properties-common
  - name:    Add Docker GPG key
    apt_key: url=https://download.docker.com/linux/ubuntu/gpg
  - name:    Add Docker APT repository
    apt_repository:
      repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ansible_distribution_release}} stable
  - name:    Install Docker
    apt:     name=docker-ce

Get Metadata:

$ ansible -m debug -a 'var=hostvars' -i hosts masters

Deploy Nodes on Scaleway:

$ scw --region=par1 create --commercial-type=START1-XS --ip-address=51.15.255.190 --ipv6=false --name="swarm-manager-1" --tmp-ssh-key=false  bc75c00b
$ scw start swarm-manager-1

Deploy Docker with Ansible:

$ ansible-playbook --user=root --private-key=~/Personal/key.pem  /etc/ansible/plabooks/docker.yml


Resources:

- https://gist.github.com/rbq/886587980894e98b23d0eee2a1d84933