No description
Find a file
2016-07-20 01:14:05 -04:00
defaults Use localhost for the common name 2016-07-20 01:14:05 -04:00
files Fix test brokeness 2016-07-20 00:25:25 -04:00
meta Add galaxy meta data 2016-07-13 08:59:12 -04:00
tasks Differet approach to alt name. 2016-07-17 14:51:27 -04:00
templates Differet approach to alt name. 2016-07-17 14:51:27 -04:00
tests Fix test brokeness 2016-07-20 00:25:25 -04:00
vars Initial 2016-07-13 01:25:00 -04:00
.gitignore Fix test brokeness 2016-07-20 00:25:25 -04:00
.travis.yml Add travis file 2016-07-13 02:16:36 -04:00
README.md Force commit 2016-07-13 07:55:31 -04:00

Build Status

Create Local Registry

Create a local Docker registry suitable for testing and development. The resulting registry includes self-signed certificates and basic username/password authentication.

Requirements

  • Ansible 2.1 with the lastest changes to the docker_container module. If you're not running Ansible from source, grab a copy of the latest docker_container.py and place it in a library directory.
  • Docker daemon

Role Variables

registry_name

Name of the container running the registry service. Defaults to registry.

registry_auth_path

Path to the directory containing the password file. Defaults to files/auth.

registry_auth_file

Name of the password file. Defaults to htpasswd.

registry_cert_path

Path to the directory containing the domain certifiate and key files. Defaults to files/certs.

registry_cert_file

Name of the domain certificate file. Defaults to domain.crt.

registry_key_file

Name of the domain key file. Defaults to domain.key.

registry_port

Map the registry port to this host port. Defaults to 5000.

registry_users

List of users. Each user is an object containing username and password keys. See [defaults/main.yml] for an example.

registry_host:

The hostname or IP address. Defaults to localhost.

registry_create_certs

Generate self-signed certificates. Defaults to true.

Example Playbook

Below is an example playbook that stands up a registry and then makes some assertions, testing that the registry is running and users can actually authenticate.

#
# example_playbook.yml
#
- name: Test role-local-registry 
  hosts: localhost
  connection: local
  gather_facts: no
  roles:
    - role: role-local-registry

- name: Test the registry
  hosts: localhost
  connection: local
  gather_facts: no
  tasks:

    - command: "{% raw %}docker inspect --format='{{ .State.Running }}' registry{% endraw %}"
      register: container_state

    - name: Should be running
      assert:
        that:
          - container_state.stdout == 'true' 
          - 
    - name: Authenticate each user with the registry
      docker_login:
        registry_url: "{{ registry_host }}:{{ registry_port }}"
        username: "{{ item.username }}"
        password: "{{ item.password }}"
      with_items: "{{ registry_users }}"

Here's a sample vars file, defining the set of users to create and the host IP and port:

---
registry_users:
  - username: user0
    password: Apassword! 
  - username: user1 
    password: Bpassword! 
registry_host: 192.168.99.100 
registry_port: 5000

And finally, to execute the above:

$ ansible-playbook example_playbook.yml -e"@vars.yml"

License

MIT

Contributors

@chouseknecht