Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gitlab_runner can not register a runner "sudo: unable to resolve host xxx" #65189

Closed
gregbkr opened this issue Nov 22, 2019 · 3 comments
Closed
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback.

Comments

@gregbkr
Copy link

gregbkr commented Nov 22, 2019

SUMMARY

First time I try to install gitlab-runner via ansible.

I am using the latest python-gitlab:

ubuntu@hello:~$ pip freeze | grep python-gitlab
You are using pip version 8.1.1, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
python-gitlab==1.13.0

Go an error:

fatal: [34.229.17.108]: FAILED! => {"changed": false, "module_stderr": "Shared connection to 34.229.17.108 closed.\r\n", "module_stdout": "sudo: unable to resolve host hello\r\nTraceback (most recent call last):\r\n  File \"/home/ubuntu/.ansible/tmp/ansible-tmp-1574434076.85-45948753869667/AnsiballZ_gitlab_runner.py\", line 102, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/ubuntu/.ansible/tmp/ansible-tmp-1574434076.85-45948753869667/AnsiballZ_gitlab_runner.py\", line 94, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/ubuntu/.ansible/tmp/ansible-tmp-1574434076.85-45948753869667/AnsiballZ_gitlab_runner.py\", line 40, in invoke_module\r\n    runpy.run_module(mod_name='ansible.modules.source_control.gitlab_runner', init_globals=None, run_name='__main__', alter_sys=True)\r\n  File \"/usr/lib/python2.7/runpy.py\", line 188, in run_module\r\n    fname, loader, pkg_name)\r\n  File \"/usr/lib/python2.7/runpy.py\", line 82, in _run_module_code\r\n    mod_name, mod_fname, mod_loader, pkg_name)\r\n  File \"/usr/lib/python2.7/runpy.py\", line 72, in _run_code\r\n    exec code in run_globals\r\n  File \"/tmp/ansible_gitlab_runner_payload_gQQjo2/ansible_gitlab_runner_payload.zip/ansible/modules/source_control/gitlab_runner.py\", line 392, in <module>\r\n  File \"/tmp/ansible_gitlab_runner_payload_gQQjo2/ansible_gitlab_runner_payload.zip/ansible/modules/source_control/gitlab_runner.py\", line 357, in main\r\nTypeError: __init__() got an unexpected keyword argument 'password'\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
ISSUE TYPE
  • Bug Report
COMPONENT NAME

Python-gitlab=1.13.0

ANSIBLE VERSION
ansible 2.9.1
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/rc/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.12 (default, Oct  8 2019, 14:14:10) [GCC 5.4.0 20160609]
CONFIGURATION
Empty
OS / ENVIRONMENT

Run ansible from: Ubuntu 16.04 laptop
Target: AWS ubuntu 16.04

STEPS TO REPRODUCE
ansible-playbook -u ubuntu --private-key ~/.ssh/id_rsa_aws -i ec2.py gitlab-runner.yml
[DEPRECATION WARNING]: The TRANSFORM_INVALID_GROUP_CHARS settings is set to allow bad characters in group names by default, this will change, but still 
be user configurable on deprecation. This feature will be removed in version 2.10. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details


PLAY [34.229.17.108] *************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************
ok: [34.229.17.108]

TASK [Install gitlab Module for Python] ******************************************************************************************************************
ok: [34.229.17.108]

TASK [Register runner] ***********************************************************************************************************************************
fatal: [34.229.17.108]: FAILED! => {"changed": false, "module_stderr": "Shared connection to 34.229.17.108 closed.\r\n", "module_stdout": "sudo: unable to resolve host hello\r\nTraceback (most recent call last):\r\n  File \"/home/ubuntu/.ansible/tmp/ansible-tmp-1574434076.85-45948753869667/AnsiballZ_gitlab_runner.py\", line 102, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/ubuntu/.ansible/tmp/ansible-tmp-1574434076.85-45948753869667/AnsiballZ_gitlab_runner.py\", line 94, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/ubuntu/.ansible/tmp/ansible-tmp-1574434076.85-45948753869667/AnsiballZ_gitlab_runner.py\", line 40, in invoke_module\r\n    runpy.run_module(mod_name='ansible.modules.source_control.gitlab_runner', init_globals=None, run_name='__main__', alter_sys=True)\r\n  File \"/usr/lib/python2.7/runpy.py\", line 188, in run_module\r\n    fname, loader, pkg_name)\r\n  File \"/usr/lib/python2.7/runpy.py\", line 82, in _run_module_code\r\n    mod_name, mod_fname, mod_loader, pkg_name)\r\n  File \"/usr/lib/python2.7/runpy.py\", line 72, in _run_code\r\n    exec code in run_globals\r\n  File \"/tmp/ansible_gitlab_runner_payload_gQQjo2/ansible_gitlab_runner_payload.zip/ansible/modules/source_control/gitlab_runner.py\", line 392, in <module>\r\n  File \"/tmp/ansible_gitlab_runner_payload_gQQjo2/ansible_gitlab_runner_payload.zip/ansible/modules/source_control/gitlab_runner.py\", line 357, in main\r\nTypeError: __init__() got an unexpected keyword argument 'password'\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

PLAY RECAP ***********************************************************************************************************************************************
34.229.17.108              : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0  

- hosts: 34.229.17.108
  become: true
  tasks:

    - name: Install gitlab Module for Python
      pip:
        name: python-gitlab

    - name: "Register runner"
      gitlab_runner:
        api_url: https://gitlab.com/  # <-- using gitlab public
        api_token: 'K4NUT1YtyQJxxxxxxx'  # <-- has read/write access to api
        registration_token: '5gBXq-amjr-pkjzxxxxxx'
        description: testing
        state: present
        active: True
        tag_list: ['docker']
        run_untagged: False
        locked: False
EXPECTED RESULTS

Should configure 1 runner.

ACTUAL RESULTS
fatal: [34.229.17.108]: FAILED! => {
    "changed": false, 
    "module_stderr": "OpenSSH_7.2p2 Ubuntu-4ubuntu2.8, OpenSSL 1.0.2g  1 Mar 2016\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 17926\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 1\r\nShared connection to 34.229.17.108 closed.\r\n", 
    "module_stdout": "sudo: unable to resolve host hello\r\nTraceback (most recent call last):\r\n  File \"/home/ubuntu/.ansible/tmp/ansible-tmp-1574434377.5-99969599478078/AnsiballZ_gitlab_runner.py\", line 102, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/ubuntu/.ansible/tmp/ansible-tmp-1574434377.5-99969599478078/AnsiballZ_gitlab_runner.py\", line 94, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/ubuntu/.ansible/tmp/ansible-tmp-1574434377.5-99969599478078/AnsiballZ_gitlab_runner.py\", line 40, in invoke_module\r\n    runpy.run_module(mod_name='ansible.modules.source_control.gitlab_runner', init_globals=None, run_name='__main__', alter_sys=True)\r\n  File \"/usr/lib/python2.7/runpy.py\", line 188, in run_module\r\n    fname, loader, pkg_name)\r\n  File \"/usr/lib/python2.7/runpy.py\", line 82, in _run_module_code\r\n    mod_name, mod_fname, mod_loader, pkg_name)\r\n  File \"/usr/lib/python2.7/runpy.py\", line 72, in _run_code\r\n    exec code in run_globals\r\n  File \"/tmp/ansible_gitlab_runner_payload_k5lp1W/ansible_gitlab_runner_payload.zip/ansible/modules/source_control/gitlab_runner.py\", line 392, in <module>\r\n  File \"/tmp/ansible_gitlab_runner_payload_k5lp1W/ansible_gitlab_runner_payload.zip/ansible/modules/source_control/gitlab_runner.py\", line 357, in main\r\nTypeError: __init__() got an unexpected keyword argument 'password'\r\n", 
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", 
    "rc": 1
}

Thank you.
Greg.

@ansibot
Copy link
Contributor

ansibot commented Nov 22, 2019

Files identified in the description:
None

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback. labels Nov 22, 2019
@sivel
Copy link
Member

sivel commented Nov 22, 2019

I believe this is due to #64770

Backports of the fix are open for the 2.9.x and 2.8.x releases.

In the mean time, you can work around this by installing an older version of the python-gitlab library.

pip install -U 'python-gitlab<1.13'

!component =lib/ansible/modules/source_control/gitlab/gitlab_runner.py

If you have further questions please stop by IRC or the mailing list:

@sivel sivel closed this as completed Nov 22, 2019
@gregbkr
Copy link
Author

gregbkr commented Nov 22, 2019

OK, thank you for your quick answer. With 1.12.1 it is working further.
However I don't understand what's ansible installing:

changed: [34.229.17.108] => {
    "changed": true, 
    "invocation": {
        "module_args": {
            "access_level": "ref_protected", 
            "active": true, 
            "api_password": null, 
            "api_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "api_url": "https://gitlab.com/", 
            "api_username": null, 
            "description": "testing", 
            "locked": false, 
            "maximum_timeout": 3600, 
            "registration_token": "5gBXq-amjr-pkjzf9C5p", 
            "run_untagged": false, 
            "state": "present", 
            "tag_list": [
                "docker"
            ], 
            "url": null, 
            "validate_certs": true
        }
    }, 
    "msg": "Successfully created or updated the runner testing", 
    "runner": {
        "access_level": "ref_protected", 
        "active": true, 
        "architecture": null, 
        "contacted_at": null, 
        "description": "testing", 
        "groups": [], 
        "id": 1355042, 
        "ip_address": "54.164.163.245", 
        "is_shared": false, 
        "locked": false, 
        "maximum_timeout": 3600, 
        "name": null, 
        "online": null, 
        "platform": null, 
        "projects": [
            {
                "avatar_url": null, 
                "created_at": "2019-10-21T10:21:38.005Z", 
                "default_branch": "master", 
                "description": "", 
                "forks_count": 0, 
                "http_url_to_repo": "https://gitlab.com/gregbkr/aws.git", 
                "id": 14930030, 
                "last_activity_at": "2019-11-22T15:01:21.264Z", 
                "name": "aws", 
                "name_with_namespace": "gregbkr / aws", 
                "namespace": {
                    "avatar_url": "/uploads/-/system/user/avatar/3883958/avatar.png", 
                    "full_path": "gregbkr", 
                    "id": 5066154, 
                    "kind": "user", 
                    "name": "gregbkr", 
                    "parent_id": null, 
                    "path": "gregbkr", 
                    "web_url": "https://gitlab.com/gregbkr"
                }, 
                "path": "aws", 
                "path_with_namespace": "gregbkr/aws", 
                "readme_url": "https://gitlab.com/gregbkr/aws/blob/master/README.md", 
                "ssh_url_to_repo": "git@gitlab.com:gregbkr/aws.git", 
                "star_count": 0, 
                "tag_list": [], 
                "web_url": "https://gitlab.com/gregbkr/aws"
            }
        ], 
        "revision": null, 
        "run_untagged": false, 
        "status": "not_connected", 
        "tag_list": [
            "docker"
        ], 
        "token": "Tmicdw_d1zyCiYMx1zMJ", 
        "version": null
    }
}
META: ran handlers
META: ran handlers

PLAY RECAP ***********************************************************************************************************************************************
34.229.17.108              : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

But on the target I see nothing:

ubuntu@hello:~$ sudo cat /etc/gitlab-runner/config.toml
concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

ubuntu@hello:~$ sudo gitlab-runner list
Runtime platform                                    arch=amd64 os=linux pid=4112 revision=577f813d version=12.5.0
Listing configured runners                          ConfigFile=/etc/gitlab-runner/config.toml

And a disconnected runner is present in gitlab/setting/runner
image

Any documentation I should read?
Thank you for your help.

@sivel sivel removed the needs_triage Needs a first human triage before being processed. label Dec 2, 2019
@ansible ansible locked and limited conversation to collaborators Dec 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback.
Projects
None yet
Development

No branches or pull requests

3 participants