Skip to content
Snippets Groups Projects
Commit ea3d71a3 authored by fejao's avatar fejao
Browse files

Merge branch 'Adding_role_docker_images' into 'main'

Adding role docker images

See merge request !4
parents 8148d5d1 d1ecdcda
Branches
No related tags found
Loading
Showing
with 246 additions and 30 deletions
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
- [ ] finish the roles for deploying the **c3InfoDesk Printer** - [ ] finish the roles for deploying the **c3InfoDesk Printer**
- [x] dependencies - [x] dependencies
- [x] clone_repositories - [x] clone_repositories
- [ ] docker_images - [x] docker_images
- [ ] docker_containers - [ ] docker_containers
- [ ] set ansible-lint - [ ] set ansible-lint
...@@ -22,6 +22,7 @@ Here are the used roles: ...@@ -22,6 +22,7 @@ Here are the used roles:
- [dependencies](roles/dependencies/README.md) - [dependencies](roles/dependencies/README.md)
- [clone_repositories](roles/clone_repositories/README.md) - [clone_repositories](roles/clone_repositories/README.md)
- [docker_images](roles/docker_images/README.md)
## License ## License
......
...@@ -11,3 +11,17 @@ var_setted_only_group_vars: "MESSAGE FROM GROUP_VARS ONLY" ...@@ -11,3 +11,17 @@ var_setted_only_group_vars: "MESSAGE FROM GROUP_VARS ONLY"
### roles/clone_repositories ### roles/clone_repositories
### ###
c3infodesk_printer_folder: "Coding/c3infodesk-printer" c3infodesk_printer_folder: "Coding/c3infodesk-printer"
###
### roles/docker_images
###
c3infodesk_printer_folder_docker: "Coding/c3infodesk-printer/docker"
c3infodesk_printer_folder_docker_cups: "Coding/c3infodesk-printer/docker/cups"
c3infodesk_printer_folder_docker_app: "Coding/c3infodesk-printer/docker/app"
c3infodesk_printer_folder_docker_proxy: "Coding/c3infodesk-printer/docker/proxy"
c3infodesk_printer_docker_img_cups_name: "c3printing-cups"
c3infodesk_printer_docker_img_cups_tag: "latest"
c3infodesk_printer_docker_img_app_name: "c3printing-app"
c3infodesk_printer_docker_img_app_tag: "latest"
c3infodesk_printer_docker_img_proxy_name: "c3printing-proxy"
c3infodesk_printer_docker_img_proxy_tag: "latest"
...@@ -20,3 +20,11 @@ docker_users: [test-user] ...@@ -20,3 +20,11 @@ docker_users: [test-user]
### ###
# c3infodesk_printer_repo_clone: true # c3infodesk_printer_repo_clone: true
c3infodesk_printer_repo_new_branch_name: "test_branch" c3infodesk_printer_repo_new_branch_name: "test_branch"
###
### roles/docker_images
###
# Set this variables, only if you need to debug creating the docker images
# c3infodesk_printer_debug_create_image_cups: true
# c3infodesk_printer_debug_create_image_app: true
# c3infodesk_printer_debug_create_image_proxy: true
...@@ -4,5 +4,4 @@ ...@@ -4,5 +4,4 @@
- hosts: - hosts:
- example_servers_group - example_servers_group
roles: roles:
# - dependencies
- clone_repositories - clone_repositories
---
# Runs example for
- hosts:
- example_servers_group
roles:
- docker_images
galaxy_info: galaxy_info:
author: your name role_name: clone_repositories
description: your role description description: Role to clone the repositories used from c3InfoDesk sytems
company: your company (optional) author: fejao
company: cccv.de
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc) license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.10
min_ansible_version: 2.1
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
galaxy_tags: [] galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
# dependencies: [] # dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above, # List your role dependencies here, one per line. Be sure to remove the '[]' above,
......
...@@ -4,7 +4,7 @@ galaxy_info: ...@@ -4,7 +4,7 @@ galaxy_info:
author: fejao author: fejao
company: cccv.de company: cccv.de
license: license (GPL-2.0-or-later, MIT, etc) license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.1 min_ansible_version: 2.10
galaxy_tags: [] galaxy_tags: []
dependencies: [] dependencies: []
# docker_images
This ansible-role for dealing with creating the docker images necessary for deploying the system used from **c3infodesk**.
## Requirements
- To have [ansible](https://docs.ansible.com/ansible/latest/installation_guide/installation_distros.html) installed at your system.
- Set your **remote_user** configuration at the **ansible.cfg** file.
- Set your **inventories/host_vars/<TARGET_NAME>** file.
## Role Variables
Here are the variables setted:
- ### From: inventories/host_vars/<TARGET_NAME>
Here are the variables that you should be changing for your own deployment.
- **c3infodesk_printer_debug_create_image_cups**: DEFAULT=<NOT_SETTED>
- If you want to debug the output from creating the image for CUPS
- **c3infodesk_printer_debug_create_image_app**: DEFAULT=<NOT_SETTED>
- If you want to debug the output from creating the image for the APP
- **c3infodesk_printer_debug_create_image_proxy**: DEFAULT=<NOT_SETTED>
- If you want to debug the output from creating the image for the PROXY
- ### From: inventories/group_vars/<TARGET_GROUP>
Please don't cahnge the default values at this file. If you need to update them, use the **inventories/host_vars/<TARGET_NAME>** file.
- **c3infodesk_printer_folder_docker**: DEFAULT="Coding/c3infodesk-printer/docker"
- The folder where the configuration from docker used for the system
- **c3infodesk_printer_folder_docker_cups**: DEFAULT="Coding/c3infodesk-printer/docker/cups"
- The folder where the configuration from docker CUPS used for the system
- **c3infodesk_printer_folder_docker_app**: DEFAULT="Coding/c3infodesk-printer/docker/app"
- The folder where the configuration from docker APP used for the system
- **c3infodesk_printer_folder_docker_proxy**: DEFAULT="Coding/c3infodesk-printer/docker/proxy"
- The folder where the configuration from docker PROXY used for the system
- **c3infodesk_printer_docker_img_cups_name**: DEFAULT="c3printing-cups"
- The name of the image to be set for the CUPS
- **c3infodesk_printer_docker_img_cups_tag**: DEFAULT="latest"
- The tag name/number to be setted for the CUPS image
- **c3infodesk_printer_docker_img_app_name**: DEFAULT="c3printing-app"
- The name of the image to be set for the APP
- **c3infodesk_printer_docker_img_app_tag**: DEFAULT="latest"
- The tag name/number to be setted for the APP image
- **c3infodesk_printer_docker_img_proxy_name**: DEFAULT="c3printing-proxy"
- The name of the image to be set for the PROXY
- **c3infodesk_printer_docker_img_proxy_tag**: DEFAULT="latest"
- The tag name/number to be setted for the PROXY image
- ### From: roles/clone-repositories/defaults/main.yml
Don't change the values at this file, if you need to change them, change it at the **inventories/host_vars/<TARGET_NAME>** file
- **c3infodesk_printer_debug_create_image_cups**: DEFAULT=false
- **c3infodesk_printer_debug_create_image_app**: DEFAULT=false
- **c3infodesk_printer_debug_create_image_proxy**: DEFAULT=false
## Dependencies
The role dependencies are:
- [dependencies(role)](roles/dependencies/README.md)
- [clone_reposiries](roles/clone_repositories/README.md)
## Example Playbook
- ### Using the provided example
For using the playbook **playbook_example_04_docker_images.yml** file you only nned to:
- Change the user at the **ansible.cfg** file at the field **remote_user** for acessing your target.
- Update the file **inventories/host_vars/example_server.yml** and change the value for **ansible_become_pass** from the **remote_user**
- Update the **inventories/hosts** file and change the **example_server** with the IP address from your target.
And run the command:
```bash
ansible-playbook -i inventories/hosts playbook_example_04_docker_images.yml
```
- ### Setting your own example
After setting your variables at **inventories/host_vars/<HOST_NAME>**, you can add this role to your playbook as a regular role.
Here is an example using the **<HOST_NAME>** as **test_servers**
```yaml
- hosts:
- test_servers
roles:
- docker_images
```
And call the playbook as:
```bash
ansible-playbook -i <INVENTORY> <PLAYBOOK_NAME>.yml
```
## License
MIT / BSD
## Author Information
![fejao logo](../../files/from_authors/fejao_logo_circle.png "fejao") [https://chaos.social/@fejao](https://chaos.social/@fejao)
---
# defaults file for docker-images
c3infodesk_printer_debug_create_image_cups: false
c3infodesk_printer_debug_create_image_app: false
c3infodesk_printer_debug_create_image_proxy: false
galaxy_info:
role_name: docker_images
description: Role to clone the repositories used from c3InfoDesk sytems
author: fejao
company: cccv.de
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.10
galaxy_tags: []
# dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
- role: dependencies
- role: clone_repositories
---
# Creates the c3infodesk-app docker image
- name: APP | Check if the image already exists on the system
community.docker.docker_image_info:
name: "{{ c3infodesk_printer_docker_img_app_name }}"
register: result_check_image
- name: APP | Check image exists answer
ansible.builtin.debug:
msg: "Image already exists on target"
when: result_check_image.images | length > 0
- name: APP | Build the docker image
ansible.builtin.command:
cmd: docker build . -t "{{ c3infodesk_printer_docker_img_app_name }}":"{{ c3infodesk_printer_docker_img_app_tag }}" -f docker/app/Dockerfile
args:
chdir: "{{ c3infodesk_printer_folder }}"
register: build_img_result
when: result_check_image.images | length <= 0
- name: APP | DEBUG -> Output from creating the docker image
ansible.builtin.debug:
msg: "{{ build_img_result }}"
when:
- c3infodesk_printer_debug_create_image_app | bool
- build_img_result is defined
\ No newline at end of file
---
# Creates the c3infodesk-cups docker image
###
### LINKS
###
# https://docs.ansible.com/ansible/latest/collections/community/docker/docker_image_module.html
- name: CUPS | Check if the image already exists on the system
community.docker.docker_image_info:
name: "{{ c3infodesk_printer_docker_img_cups_name }}"
register: result_check_image
- name: CUPS | Check image exists answer
ansible.builtin.debug:
msg: "Image already exists on target"
when: result_check_image.images | length > 0
- name: CUPS | Build the docker image
ansible.builtin.command:
cmd: docker build . -t "{{ c3infodesk_printer_docker_img_cups_name }}":"{{ c3infodesk_printer_docker_img_cups_tag }}" -f docker/cups/Dockerfile
args:
chdir: "{{ c3infodesk_printer_folder }}"
register: build_img_result
when: result_check_image.images | length <= 0
- name: CUPS | DEBUG -> Output from creating the docker image
ansible.builtin.debug:
msg: "{{ build_img_result }}"
when:
- c3infodesk_printer_debug_create_image_cups | bool
- build_img_result is defined
\ No newline at end of file
---
# Creates the c3infodesk-proxy docker image
- name: PROXY | Check if the image already exists on the system
community.docker.docker_image_info:
name: "{{ c3infodesk_printer_docker_img_proxy_name }}"
register: result_check_image
- name: PROXY | Check image exists answer
ansible.builtin.debug:
msg: "Image already exists on target"
when: result_check_image.images | length > 0
- name: PROXY | Build the docker image
ansible.builtin.command:
cmd: docker build . -t "{{ c3infodesk_printer_docker_img_proxy_name }}":"{{ c3infodesk_printer_docker_img_proxy_tag }}" -f docker/proxy/Dockerfile
args:
chdir: "{{ c3infodesk_printer_folder }}"
register: build_img_result
when: result_check_image.images | length <= 0
- name: PROXY | DEBUG -> Output from creating the docker image
ansible.builtin.debug:
msg: "{{ build_img_result }}"
when:
- c3infodesk_printer_debug_create_image_cups | bool
- build_img_result is defined
\ No newline at end of file
---
# tasks file for docker-images
- import_tasks: docker_image_cups.yml
- import_tasks: docker_image_app.yml
- import_tasks: docker_image_proxy.yml
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment