I'm trying to deploy a Docker service into swarm but always ending up with running container on my localhost (the one I use as a docker swarm manager) and no service
Here's my setup:
I have 3 node Docker (v. 1.12.1) swarm that includes one host running as manager and two worker nodes all running on CentOS 7. On the manager node (localhost) I run Ansible (v. 2.1.1.0) playbook and the swarm is already configured and is running
Swarm: active
NodeID: d9h5xa832ax7wzeq8q44fjld3
Is Manager: true
ClusterID: 9cztoin3gy2ntbwehsmrkjuxi
Managers: 1
Nodes: 3
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Heartbeat Tick: 1
Election Tick: 3
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Node Address: 10.25.190.209
Starting with a playbook that has this code
- hosts: localhost
name: Run JMeter test
vars_files:
- user.config.yml
vars:
execute_tpcds_test : "{{ run_tpcds_test }}"
roles:
- { role: run_jmeter, when: execute_tpcds_test is defined and execute_tpcds_test ==1 }
Which calls this role:
- name: Deploy tpcds_tpg service to swarm
docker_service:
project_name: tpcds-tpg
definition:
version: '2'
services:
run_tests:
image: 'pbench/tpcds_tpg'
volumes:
- /opt/pbench/run_output/
command: ./run_jmeter.sh "{{jmeter_output_dir}}"
register: output
- debug: var=output
When I run ansible-playbook ./site.yml
I end up with a running container. Doing docker ps -a
displays
[pdo@sdl02133 tpcds-tpg]$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fef245b41365 pbench/tpcds_tpg "./run_jmeter.sh /opt" 21 seconds ago Up 20 seconds tpcdstpg_run_tests_1
And doing docker service ls
shows no services running so it looks like docker_service
deploys my image as a local container and not as a service on the swarm
So my assumption was that if I have an active swarm on the machine that is a swarm manager and I use Ansible docker_service
module, then it will automatically be aware of the swarm and deploy the service to it. Looks like my assumption is wrong and I cannot find any docs, blog posts, etc. that would hint me what to do and what I am missing. Ansible experts please help!