|
1 year ago | |
---|---|---|
defaults | 1 year ago | |
meta | 1 year ago | |
molecule/default | 1 year ago | |
tasks | 1 year ago | |
templates | 1 year ago | |
.gitignore | 1 year ago | |
.yamllint | 1 year ago | |
LICENSE | 1 year ago | |
README.md | 1 year ago |
Download a git repository which has a Dockerfile, build it locally (or remotely), push it to a registry or just download a Docker image and push it to a registry. Also create a systemd service to manage it.
git_repository
: The repository in which the dockerfile is located.git_repository_destination
: Local path in which to clone the git repository.git_repository_extra_path
: Extra path inside the cloned repo to the
directory containing the Dockerfilegit_repository_tag
: Version to use of the git repository.service_name
: Name of the systemd service.docker_registry
: Domain of the registry with write access.docker_registry_read
: Domain of the registry with read access.registry_user
: User used to authenticate with the registry.registry_password
: Password used to authenticate with the registry.docker_image
: If you want to download a docker image and not a git repositorydocker_image_tag
: Docker tag.docker_command
: Docker command used to launch the container.docker_data_directories
: List of directories where the data is going to be
saved on the host.remote_build
: Whether to build the docker remotely or locally [Default:
False
]None.
- hosts: servers
vars:
remote_build: True
git_repository: https://github.com/nginxinc/docker-nginx
git_repository_destination: /tmp/docker-nginx
git_repository_extra_path: stable/stretch
git_repository_tag: master
service_name: git-nginx
docker_data_directories:
- "/root/docker/git-nginx/data"
- "/root/docker/git-nginx/auth"
docker_registry: "docker-registry:5000"
docker_registry_read: "{{ docker_registry }}"
registry_user: testuser
registry_password: testpassword
docker_image_tag: latest
docker_command: /usr/bin/docker run --rm -i --name "{{ service_name }}" -p 8081:80 "{{ docker_registry_read }}/{{ service_name }}"
roles:
- { role: deploy-docker}
To test the role you need molecule.
And vagrant installed with libvirt
I’ve tried to test the construction of the docker in one machine and installing
the service in other, but local_action
or delegate_to
are little fuckers to
simulate.
The delegate_to
approach fails because it tries to ssh back with no user, so
it doesn’t matter if you copy the ssh keys there it will keep on failing.
Another approach I took was to copy all the structure of the role on the machine
building the docker and modify the molecule/default/playbook.yml
so as to run
the playbook from there so the local_action
works. The problem is that you
have to run the playbook on a command
so you are forced to use the
changed_when: false
therefore not testing the idempotence of the rol.
I give up on trying to test this role with the option remote_build = False
. If
anyone is interested I left my trails on this role:
Therefore the default
case is for remote_build == True
if you feel strong
enough to test the other case, please make a new molecule scenery. Both in this
role and in the ui-registry one.
molecule test
GPL3
drymer [ EN ] autistici.org lyz [ EN ] riseup.net