Add ansible playbook files for docker image creation, docker network creation/deletion, docker container creation/deletion
diff --git a/xos/synchronizer/steps/sync_controller_images.yaml b/xos/synchronizer/steps/sync_controller_images.yaml
new file mode 100644
index 0000000..d7b5c09
--- /dev/null
+++ b/xos/synchronizer/steps/sync_controller_images.yaml
@@ -0,0 +1,33 @@
+---
+- hosts: {{ swarm_manager_address }}
+ become: true
+ tasks:
+
+ {% if not delete -%}
+
+ - name: make a directory for swarm archive image
+ file:
+ path: {{ image_dir }}
+ state: directory
+ mode: 0755
+ - name: copy docker image file(.tar) to swarm manager node
+ copy:
+ src: {{ image_file_path }}
+ dest: {{ image_file_path }}
+ - name: load a docker image from archive file(example-abc.tar)
+ shell: docker load -i {{ image_file_path }}
+ - name: change tag information
+ shell: docker tag {{ image_name }} {{ swarm_manager_address }}:{{ docker_registry_port }}/{{ image_name }}:{{ image_tag }}
+ - name: push docker image to local registry
+ docker_image:
+ name: {{ swarm_manager_address }}:{{ docker_registry_port }}/{{ image_name }}
+ tag: {{ image_tag }}
+ push: yes
+ - name: Inspect a image
+ docker_image_facts:
+ name: {{ swarm_manager_address }}:{{ docker_registry_port }}/{{ image_name }}:{{ image_tag }}
+
+ {% else -%}
+ # Don't delete a docker image on docker registry and repository
+ {% endif %}
+
diff --git a/xos/synchronizer/steps/sync_controller_networks.yaml b/xos/synchronizer/steps/sync_controller_networks.yaml
new file mode 100644
index 0000000..6ca2c90
--- /dev/null
+++ b/xos/synchronizer/steps/sync_controller_networks.yaml
@@ -0,0 +1,18 @@
+---
+- hosts: {{ swarm_manager_address }}
+ become: true
+ tasks:
+ {% if delete -%}
+ - name: delete a docker network '{{ network_name }}'
+ shell: docker network rm {{ network_name }}
+ {% elif duplicated -%}
+ - name: network list on swarm cluster
+ shell: docker network ls
+ - name: network inspection '{{ network_name }}'
+ shell: docker network inspect {{ network_name }}
+ {% else -%}
+ - name: create a docker network '{{ network_name }}'
+ shell: docker network create {{ opt_driver }} {{ opt_ipam_driver }} {{ opt_subnet }} {{ opt_gateway }} {{ opt_ipam_neutron_opt }} {{ network_name }}
+ - name: network inspection '{{ network_name }}'
+ shell: docker network inspect {{ network_name }}
+ {% endif -%}
diff --git a/xos/synchronizer/steps/sync_instances.yaml b/xos/synchronizer/steps/sync_instances.yaml
new file mode 100644
index 0000000..a129d02
--- /dev/null
+++ b/xos/synchronizer/steps/sync_instances.yaml
@@ -0,0 +1,45 @@
+---
+- hosts: {{ swarm_manager_address }}
+ become: true
+ tasks:
+ {% if delete -%}
+
+ - name: delete swarm service '{{ swarm_service_name }}'
+ shell: docker service rm {{ swarm_service_name }}
+ - name: remove the directory {{ host_volume_path }}
+ file:
+ path={{ host_volume_path }}
+ state=absent
+
+ {% elif update -%}
+
+ - name: Create host volume directory to share to docker container
+ file:
+ path={{ host_volume_path }}
+ state=directory
+ - name: update swarm service '{{ swarm_service_name }}'
+ shell: docker service update --force {{ volume }} {{ swarm_service_name }}
+ - name: get status of '{{ swarm_service_name }}' service
+ shell: docker service ps {{ swarm_service_name }}
+
+ {% else -%}
+
+ - name: remove the directory {{ host_volume_path }}
+ file:
+ path={{ host_volume_path }}
+ state=absent
+ - name: Create host volume directory to share to docker container
+ file:
+ path={{ host_volume_path }}
+ state=directory
+ - name: start swarm service '{{ swarm_service_name }}'
+ shell: docker service create {{ network_name }} --name {{ swarm_service_name }} {{ replica }} {{ restart_condition }} {{ volume }} {{ swarm_manager_address }}:{{ docker_registry_port }}/{{ image_name }}:{{ image_tag }}
+
+ {% endif %}
+
+
+ {% if not delete -%}
+ - name: inspect '{{ swarm_service_name }}' service of swarm mode
+ shell: docker service inspect {{ swarm_service_name }}
+ {% endif %}
+