14 January 2018

steps

  1. run shell from st3

    1. create sublime-build file

       $ nano bash.sublime-build
       {
           "cmd"       : ["$file"],
           "selector"  : "source.shell",
           "shell"     : "bash"
       }
      
  2. install ansible

    1. use pip

       $ pip install -U ansible
      
    2. setup hosts file

       $ nano /usr/local/etc/ansible/hosts
       [docker]
       dc
      
  3. create playbook yml

    1. use mysql image

       $ nano deploy.yml
       ---
       - hosts: docker
         remote_user: root
         become: yes
         gather_facts: no
         vars:
           container_name: "forestry"
           container_image: "mysql:5.5.58"
           working_dir: "/root/deploy/docker/mysql/forestry"
      
         tasks:
           - name: remove container
             docker_container:
               name: ""
               state: absent
      
           - name: create container
             docker_container:
               name: ""
               image: ""
               volumes:
                 - "/conf:/etc/mysql/"
                 - "/data:/var/lib/mysql"
               ports:
                 - "33061:3306"
               env:
                 MYSQL_ROOT_PASSWORD: 123456
               command: mysqld --character-set-server=gbk
      
  4. run playbook

    1. use deploy.sh

       $ nano deploy.sh
       ansible-playbook deploy.yml
      
    2. in st3

       press command+b
      

references

  1. ansible docker_container_module

  2. use custom command to launch mysql container with right collation



blog comments powered by Disqus