This took me longer than I want to admit to figure out, so I thought I'd post this solution here. I'm doing this on Cisco's OpenStack Private Cloud (COPC) (formerly known as Metacloud).
Problem: Want to deploy a CoreOS instance that can access docker images from a private registry. I want to do this with Ansible.
Why its hard: Not a lot of good documentation on this put in one place. I kept getting this error:
FATA[0004] Error: v1 ping attempt failed with error: Get https://10.2.3.7:5000/v1/_ping: EOF. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry 10.2.3.7:5000` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/10.2.3.7:5000/ca.crt
Really started to aggravate me.
Ansible Playbook
Here's the playbook in its final glory:
- name: Ensure Test image is up.
connection: local
hosts: local
vars_files:
- vars/metacloud_vars.yml
tasks:
- name: Ensure Test Image is up.
nova_compute:
state: present
auth_url: "{{ lookup('env', 'OS_AUTH_URL') }}"
login_username: "{{ lookup('env', 'OS_USERNAME') }}"
login_password: "{{ lookup('env', 'OS_PASSWORD') }}"
login_tenant_name: "{{ lookup('env', 'OS_TENANT_NAME') }}"
name: coreostest
image_name: "{{ coreos_image_name }}"
key_name: "{{ keypair }}"
flavor_id: "{{ m1large }}"
meta:
group: web-servers
security_groups: "{{ security_group }}"
user_data: "{{ lookup('file', 'files/coreos-cloud-config.yaml') }}"
The coreos-cloud-config.yaml file looks like this:
#cloud-config
coreos:
units:
- name: docker.service
drop-ins:
- name: 50-insecure-registry.conf
content: |
[Service]
Environment='DOCKER_OPTS=--insecure-registry=ci:5000 '
There were a few things to note:
- If I used the config_drive: yes like it said on some documentation somewhere with this then I had some problems.
- I was using a different configuration for the cloud-config that had me do files instead. Not sure why I did this, but figured it out by using the other flag. As you can see I even opened up a problem on CoreOS github repo. I think this is what you need to do in order to solve your own problems. And the reason we all need a rubber duck.
- The CoreOS documentation shows a IP address range, but I just put in the actual registry for this and it works great.
Hoping that helps someone else not struggle like I did for hours...