Blaine Story пре 3 година
родитељ
комит
74793dedc8
1 измењених фајлова са 67 додато и 22 уклоњено
  1. 67 22
      roles/docker/README.md

+ 67 - 22
roles/docker/README.md

@@ -1,38 +1,83 @@
-Role Name
-=========
+docker
+======
 
-A brief description of the role goes here.
+This role will install Docker and given a list of containers to deploy, will do the following:
+
+1. Create needed docker networks
+2. Open up necessary firewall ports
+3. Generate docker-compose files (1 per container)
+4. Ensure container user/group exists
+5. Ensure container persistent directories exist with correct perms and SELinux contexts
+6. Generate a systemd service file per container
+7. Setup systemd timers to automatically pull new and purge old container images
 
 Requirements
 ------------
 
-Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
+This role is only tested on Fedora/CentOS machines.
 
-Role Variables
---------------
+Variables
+---------
 
-A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
+container_user: user name to run containers as (will be generated if not exists)
+container_uid: uid of above user name
+container_group: group name of container_user
+container_gid: gid of above group name
 
-Dependencies
-------------
+    global_env_vars: # will be set on any container which has include_global_env_vars: true
+      - PUID={{ container_uid }}
+      - PGID={{ container_gid }}
+      - TZ=America/Los_Angeles
 
-A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
+    firewall_ports: # list of ports to open up on the host
+      - 80/tcp
+      - 443/tcp
 
-Example Playbook
-----------------
+Since this role sets up each container individually, if multiple containers need to talk directly to each other container networks must be outlined:
 
-Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
+This role sets up each container as an individual docker-compose.yml file with a 1-to-1 relationship with it's systemd service. This means we can not rely on docker-compose's built-in networking feature for connecting multiple containers together.
 
-    - hosts: servers
-      roles:
-         - { role: username.rolename, x: 42 }
+Outline any networks you need via container_networks:
+
+    container_networks:
+      - name: backend
+        driver: bridge
+        subnet: 172.21.10.0/24
+        ip_range: 172.21.10.0/24
+        gateway: 172.21.10.1
 
-License
--------
 
-BSD
+    containers:
+      - name: nginx
+        active: true
+        image: linuxserver/nginx
+        ports:
+          - 80:80
+          - 443:443
+        volumes:
+          - /opt/nginx:/config
+        include_global_env_vars: true
+        restart: unless-stopped
+        memlimit: 300m
+        networks:
+          - backend
 
-Author Information
-------------------
+        - name: mysql
+          active: true
+          image: mysql
+          volumes:
+            - /opt/mysql:/var/lib/mysql
+          include_global_env_vars: false
+          environment:
+            - MYSQL_ROOT_PASSWORD="{{ vaulted_mysql_root_password }}"
+          restart: unless-stopped
+          memlimit: 500m
+          networks:
+            - backend
+
+
+
+License
+-------
 
-An optional section for the role authors to include contact information, or a website (HTML is not allowed).
+GPLv3