Skip to content

Instantly share code, notes, and snippets.

@dariko
Created November 27, 2018 22:06
Show Gist options
  • Save dariko/1ea934f8cd7576f1b834aa10aceebaf5 to your computer and use it in GitHub Desktop.
Save dariko/1ea934f8cd7576f1b834aa10aceebaf5 to your computer and use it in GitHub Desktop.
(venv) user@dumb:/tmp/test$ for f in *yml;do echo "# $f #####";cat $f;ansible-playbook -D $f;done
# test_nouser.yml #####
- hosts: localhost
become: true
tasks:
- docker_swarm_service:
name: traefik-lb
state: absent
- docker_network:
name: traefik-net
driver: overlay
- name: Create traefik LB on manager node
docker_swarm_service:
debug: yes
name: traefik-lb
image: 'traefik:1.7'
constraints:
- "node.role==manager"
networks:
- traefik-net
publish:
- published_port: 8080
target_port: 8080
- published_port: 8081
target_port: 8081
args:
- "--defaultEntryPoints=http"
- "--entryPoints=Name:http Address::8080"
- "--entryPoints=Name:mgt Address::8081"
- "--docker"
- "--docker.swarmMode"
- "--docker.domain=traefik"
- "--docker.watch"
- "--api"
- "--api.entrypoint=mgt"
- "--api.statistics.recentErrors=100"
mounts:
- source: "/var/run/docker.sock"
target: "/var/run/docker.sock"
type: bind
- name: test idempotency
docker_swarm_service:
debug: yes
name: traefik-lb
image: 'traefik:1.7'
constraints:
- "node.role==manager"
networks:
- traefik-net
publish:
- published_port: 8080
target_port: 8080
- published_port: 8081
target_port: 8081
args:
- "--defaultEntryPoints=http"
- "--entryPoints=Name:http Address::8080"
- "--entryPoints=Name:mgt Address::8081"
- "--docker"
- "--docker.swarmMode"
- "--docker.domain=traefik"
- "--docker.watch"
- "--api"
- "--api.entrypoint=mgt"
- "--api.statistics.recentErrors=100"
mounts:
- source: "/var/run/docker.sock"
target: "/var/run/docker.sock"
type: bind
[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [localhost] *********************************************************************************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************************************************************
ok: [localhost]
TASK [docker_swarm_service] **********************************************************************************************************************************************************************************
changed: [localhost]
TASK [docker_network] ****************************************************************************************************************************************************************************************
ok: [localhost]
TASK [Create traefik LB on manager node] *********************************************************************************************************************************************************************
changed: [localhost]
TASK [test idempotency] **************************************************************************************************************************************************************************************
ok: [localhost]
PLAY RECAP ***************************************************************************************************************************************************************************************************
localhost : ok=5 changed=2 unreachable=0 failed=0
# test_user_null.yml #####
- hosts: localhost
become: true
tasks:
- docker_swarm_service:
name: traefik-lb
state: absent
- docker_network:
name: traefik-net
driver: overlay
- name: Create traefik LB on manager node
docker_swarm_service:
debug: yes
name: traefik-lb
user:
image: 'traefik:1.7'
constraints:
- "node.role==manager"
networks:
- traefik-net
publish:
- published_port: 8080
target_port: 8080
- published_port: 8081
target_port: 8081
args:
- "--defaultEntryPoints=http"
- "--entryPoints=Name:http Address::8080"
- "--entryPoints=Name:mgt Address::8081"
- "--docker"
- "--docker.swarmMode"
- "--docker.domain=traefik"
- "--docker.watch"
- "--api"
- "--api.entrypoint=mgt"
- "--api.statistics.recentErrors=100"
mounts:
- source: "/var/run/docker.sock"
target: "/var/run/docker.sock"
type: bind
- name: test idempotency
docker_swarm_service:
debug: yes
name: traefik-lb
user:
image: 'traefik:1.7'
constraints:
- "node.role==manager"
networks:
- traefik-net
publish:
- published_port: 8080
target_port: 8080
- published_port: 8081
target_port: 8081
args:
- "--defaultEntryPoints=http"
- "--entryPoints=Name:http Address::8080"
- "--entryPoints=Name:mgt Address::8081"
- "--docker"
- "--docker.swarmMode"
- "--docker.domain=traefik"
- "--docker.watch"
- "--api"
- "--api.entrypoint=mgt"
- "--api.statistics.recentErrors=100"
mounts:
- source: "/var/run/docker.sock"
target: "/var/run/docker.sock"
type: bind
[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [localhost] *********************************************************************************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************************************************************
ok: [localhost]
TASK [docker_swarm_service] **********************************************************************************************************************************************************************************
changed: [localhost]
TASK [docker_network] ****************************************************************************************************************************************************************************************
ok: [localhost]
TASK [Create traefik LB on manager node] *********************************************************************************************************************************************************************
changed: [localhost]
TASK [test idempotency] **************************************************************************************************************************************************************************************
changed: [localhost]
PLAY RECAP ***************************************************************************************************************************************************************************************************
localhost : ok=5 changed=3 unreachable=0 failed=0
# test_user_root.yml #####
- hosts: localhost
become: true
tasks:
- docker_swarm_service:
name: traefik-lb
state: absent
- docker_network:
name: traefik-net
driver: overlay
- name: Create traefik LB on manager node
docker_swarm_service:
debug: yes
name: traefik-lb
user: root
image: 'traefik:1.7'
constraints:
- "node.role==manager"
networks:
- traefik-net
publish:
- published_port: 8080
target_port: 8080
- published_port: 8081
target_port: 8081
args:
- "--defaultEntryPoints=http"
- "--entryPoints=Name:http Address::8080"
- "--entryPoints=Name:mgt Address::8081"
- "--docker"
- "--docker.swarmMode"
- "--docker.domain=traefik"
- "--docker.watch"
- "--api"
- "--api.entrypoint=mgt"
- "--api.statistics.recentErrors=100"
mounts:
- source: "/var/run/docker.sock"
target: "/var/run/docker.sock"
type: bind
- name: test idempotency
docker_swarm_service:
debug: yes
name: traefik-lb
user: root
image: 'traefik:1.7'
constraints:
- "node.role==manager"
networks:
- traefik-net
publish:
- published_port: 8080
target_port: 8080
- published_port: 8081
target_port: 8081
args:
- "--defaultEntryPoints=http"
- "--entryPoints=Name:http Address::8080"
- "--entryPoints=Name:mgt Address::8081"
- "--docker"
- "--docker.swarmMode"
- "--docker.domain=traefik"
- "--docker.watch"
- "--api"
- "--api.entrypoint=mgt"
- "--api.statistics.recentErrors=100"
mounts:
- source: "/var/run/docker.sock"
target: "/var/run/docker.sock"
type: bind
[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [localhost] *********************************************************************************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************************************************************
ok: [localhost]
TASK [docker_swarm_service] **********************************************************************************************************************************************************************************
changed: [localhost]
TASK [docker_network] ****************************************************************************************************************************************************************************************
ok: [localhost]
TASK [Create traefik LB on manager node] *********************************************************************************************************************************************************************
changed: [localhost]
TASK [test idempotency] **************************************************************************************************************************************************************************************
ok: [localhost]
PLAY RECAP ***************************************************************************************************************************************************************************************************
localhost : ok=5 changed=2 unreachable=0 failed=0
(venv) user@dumb:/tmp/test$ ansible-playbook --version
ansible-playbook 2.7.2
config file = None
configured module search path = [u'/home/user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /home/user/src/os.dari.co/venv/local/lib/python2.7/site-packages/ansible
executable location = /home/user/src/os.dari.co/venv/bin/ansible-playbook
python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]
(venv) user@dumb:/tmp/test$ sudo docker version
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:24:51 2018
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 18.06.1-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:23:15 2018
OS/Arch: linux/amd64
Experimental: false
(venv) user@dumb:/tmp/test$ s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment