Jenkins ansible docker_image ошибка реестра для отправки в докер - PullRequest
0 голосов
/ 28 ноября 2018

Я пытаюсь отправить образ докера в реестр удаленного докера через Jenkins и ANSIBLE PlayBook.

Мой ответ:

---
- hosts: localhost
  remote_user: root
  vars:
    git_branch: "{{ GIT_BRANCH|default('development') }}"
  tasks:
  - name: Log into Docker registry
    docker_login:
      registry_url: https://registry.....si
      username: user
      password: ....

  - name: Remove images
    docker_image:
      state: absent
      name: registry.....si/project/restAPI-{{ git_branch }}

  - name: Create Rest API django image
    docker_image:
      path: .
      name: registry.....si/project/restAPI-{{ git_branch }}
      push: yes

первые 2 задачи выполняются нормально, но последняяодин дает мне ошибку:

TASK [Create Rest API django image] ********************************************
task path: /var/jenkins_home/workspace/BSH-Rest-API/restAPI/build_docker.yml:18
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/cloud/docker/docker_image.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: jenkins
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo ~/.ansible/tmp/ansible-tmp-1543405086.47-86277873769632 `" && echo ansible-tmp-1543405086.47-86277873769632="` echo ~/.ansible/tmp/ansible-tmp-1543405086.47-86277873769632 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpuIkFE1 TO /var/jenkins_home/.ansible/tmp/ansible-tmp-1543405086.47-86277873769632/docker_image.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /var/jenkins_home/.ansible/tmp/ansible-tmp-1543405086.47-86277873769632/ /var/jenkins_home/.ansible/tmp/ansible-tmp-1543405086.47-86277873769632/docker_image.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /var/jenkins_home/.ansible/tmp/ansible-tmp-1543405086.47-86277873769632/docker_image.py; rm -rf "/var/jenkins_home/.ansible/tmp/ansible-tmp-1543405086.47-86277873769632/" > /dev/null 2>&1 && sleep 0'
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_OWiZI2/ansible_module_docker_image.py", line 593, in <module>
    main()
  File "/tmp/ansible_OWiZI2/ansible_module_docker_image.py", line 585, in main
    ImageManager(client, results)
  File "/tmp/ansible_OWiZI2/ansible_module_docker_image.py", line 291, in __init__
    self.present()
  File "/tmp/ansible_OWiZI2/ansible_module_docker_image.py", line 319, in present
    self.results['image'] = self.build_image()
  File "/tmp/ansible_OWiZI2/ansible_module_docker_image.py", line 514, in build_image
    for line in self.client.build(**params):
  File "/usr/local/lib/python2.7/dist-packages/docker/api/build.py", line 105, in build
    timeout=timeout,
  File "/usr/local/lib/python2.7/dist-packages/docker/utils/decorators.py", line 47, in inner
    return f(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/docker/client.py", line 135, in _post
    return self.post(url, **self._set_request_timeout(kwargs))
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 581, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(104, 'Connection reset by peer'))
fatal: [localhost]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_name": "docker_image"
    }, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_OWiZI2/ansible_module_docker_image.py\", line 593, in <module>\n    main()\n  File \"/tmp/ansible_OWiZI2/ansible_module_docker_image.py\", line 585, in main\n    ImageManager(client, results)\n  File \"/tmp/ansible_OWiZI2/ansible_module_docker_image.py\", line 291, in __init__\n    self.present()\n  File \"/tmp/ansible_OWiZI2/ansible_module_docker_image.py\", line 319, in present\n    self.results['image'] = self.build_image()\n  File \"/tmp/ansible_OWiZI2/ansible_module_docker_image.py\", line 514, in build_image\n    for line in self.client.build(**params):\n  File \"/usr/local/lib/python2.7/dist-packages/docker/api/build.py\", line 105, in build\n    timeout=timeout,\n  File \"/usr/local/lib/python2.7/dist-packages/docker/utils/decorators.py\", line 47, in inner\n    return f(self, *args, **kwargs)\n  File \"/usr/local/lib/python2.7/dist-packages/docker/client.py\", line 135, in _post\n    return self.post(url, **self._set_request_timeout(kwargs))\n  File \"/usr/local/lib/python2.7/dist-packages/requests/sessions.py\", line 581, in post\n    return self.request('POST', url, data=data, json=json, **kwargs)\n  File \"/usr/local/lib/python2.7/dist-packages/requests/sessions.py\", line 533, in request\n    resp = self.send(prep, **send_kwargs)\n  File \"/usr/local/lib/python2.7/dist-packages/requests/sessions.py\", line 646, in send\n    r = adapter.send(request, **kwargs)\n  File \"/usr/local/lib/python2.7/dist-packages/requests/adapters.py\", line 498, in send\n    raise ConnectionError(err, request=request)\nrequests.exceptions.ConnectionError: ('Connection aborted.', error(104, 'Connection reset by peer'))\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE"
}

Что я делаю не так?

1 Ответ

0 голосов
/ 29 ноября 2018

Я почти закончил, но у кого-то такая же проблема, я нашел проблему.

причина в том, что внутри параметра name есть несколько заглавных букв.

Я изменяю

name: registry.....si/project/restAPI-{{ git_branch }}

на

name: registry.....si/project/restapi-{{ git_branch }}

и теперь это работает.

...