ansible / ansible

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com.
https://www.ansible.com/
GNU General Public License v3.0
62.43k stars 23.82k forks source link

URI : Status code was 504 and not [200]: HTTP Error 504: Gateway Time-out OR Status code was -1 and not [200]: Connection failure: The read operation timed out #82501

Closed egl35720 closed 8 months ago

egl35720 commented 8 months ago

Summary

Hello everybody,

trying to deal with Global Sign Atlas API to test SSL certificate delivery I can't login to URl endpoint : 'https://emea.api.hvca.globalsign.com:8443/v2/login' However from a ssh connection on the playbook's host, I can validate successfully

The curl command returns the success code 200 and "autoriztion" and "token" values usable for other Atlas API operations

Unforyunately when I try to login with the playbook below :

        - name: `'https://emea.api.hvca.globalsign.com:8443/v2/login'
         ansible.builtin.uri:
            url: 'https://emea.api.hvca.globalsign.com:8443/v2/login'
            method: POST
            body:
              api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
              api_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
            body_format: json
            headers:
              Content-Type: application/json;charset=utf-8
              Content-length: '1792'
            client_cert: /tmp/mtls.pem
            client_key: /tmp/mtls-nopwd.key
          register: result

Issue Type

Bug Report

Component Name

ansible.builtin.uri

Ansible Version

$ ansible --version
ansible [core 2.14.5]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.11/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.11.6 (main, Oct  4 2023, 06:22:18) [GCC 12.2.1 20220924] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Configuration

Configuration...

```console # if using a version older than ansible-core 2.12 you should omit the '-t all' $ ansible-config dump -t all ACTION_WARNINGS(default) = True AGNOSTIC_BECOME_PROMPT(default) = True ANSIBLE_CONNECTION_PATH(default) = None ANSIBLE_COW_ACCEPTLIST(default) = ['bud-frogs', 'bunny', 'cheese', 'daemon', 'default', 'dragon', 'elephant-in-snake', 'elephant', 'eyes', 'hellokitty', 'kitty', 'luke-koala', 'meow', 'milk', 'moofasa', 'moose', 'ren', 'sheep', 'small', 'stegosaurus', 'stimpy', 'supermilker', 'three-eyes', 'turkey', 'turtle', 'tux', 'udder', 'vader-koala', 'vader', 'www'] ANSIBLE_COW_PATH(default) = None ANSIBLE_COW_SELECTION(default) = default ANSIBLE_FORCE_COLOR(default) = False ANSIBLE_HOME(default) = /root/.ansible ANSIBLE_NOCOLOR(default) = False ANSIBLE_NOCOWS(default) = False ANSIBLE_PIPELINING(default) = False ANY_ERRORS_FATAL(default) = False BECOME_ALLOW_SAME_USER(default) = False BECOME_PASSWORD_FILE(default) = None BECOME_PLUGIN_PATH(default) = ['/root/.ansible/plugins/become', '/usr/share/ansible/plugins/become'] CACHE_PLUGIN(default) = memory CACHE_PLUGIN_CONNECTION(default) = None CACHE_PLUGIN_PREFIX(default) = ansible_facts CACHE_PLUGIN_TIMEOUT(default) = 86400 CALLBACKS_ENABLED(default) = [] COLLECTIONS_ON_ANSIBLE_VERSION_MISMATCH(default) = warning COLLECTIONS_PATHS(default) = ['/root/.ansible/collections', '/usr/share/ansible/collections'] COLLECTIONS_SCAN_SYS_PATH(default) = True COLOR_CHANGED(default) = yellow COLOR_CONSOLE_PROMPT(default) = white COLOR_DEBUG(default) = dark gray COLOR_DEPRECATE(default) = purple COLOR_DIFF_ADD(default) = green COLOR_DIFF_LINES(default) = cyan COLOR_DIFF_REMOVE(default) = red COLOR_ERROR(default) = red COLOR_HIGHLIGHT(default) = white COLOR_OK(default) = green COLOR_SKIP(default) = cyan COLOR_UNREACHABLE(default) = bright red COLOR_VERBOSE(default) = blue COLOR_WARN(default) = bright purple CONFIG_FILE() = None CONNECTION_FACTS_MODULES(default) = {'asa': 'ansible.legacy.asa_facts', 'cisco.asa.asa': 'cisco.asa.asa_facts', 'eos': 'ansible.legacy.eos_facts', 'arista.eos.eos': 'arista.eos.eos_facts', 'frr': 'ansible.legacy.frr_facts', 'frr.frr.frr': 'frr.frr.frr_facts', 'ios': 'ansible.legacy.ios_facts', 'cisco.ios.ios': 'cisco.ios.ios_facts', 'iosxr': 'ansible.legacy.iosxr_facts', 'cisco.iosxr.iosxr': 'cisco.iosxr.iosxr_facts', 'junos': 'ansible.legacy.junos_facts', 'junipernetworks.junos.junos': 'junipernetworks.junos.junos_facts', 'nxos': 'ansible.legacy.nxos_facts', 'cisco.nxos.nxos': 'cisco.nxos.nxos_facts', 'vyos': 'ansible.legacy.vyos_facts', 'vyos.vyos.vyos': 'vyos.vyos.vyos_facts', 'exos': 'ansible.legacy.exos_facts', 'extreme.exos.exos': 'extreme.exos.exos_facts', 'slxos': 'ansible.legacy.slxos_facts', 'extreme.slxos.slxos': 'extreme.slxos.slxos_facts', 'voss': 'ansible.legacy.voss_facts', 'extreme.voss.voss': 'extreme.voss.voss_facts', 'ironware': 'ansible.legacy.ironware_facts', 'community.network.ironware': 'community.network.ironware_facts'} CONNECTION_PASSWORD_FILE(default) = None COVERAGE_REMOTE_OUTPUT(default) = None COVERAGE_REMOTE_PATHS(default) = * DEFAULT_ACTION_PLUGIN_PATH(default) = ['/root/.ansible/plugins/action', '/usr/share/ansible/plugins/action'] DEFAULT_ALLOW_UNSAFE_LOOKUPS(default) = False DEFAULT_ASK_PASS(default) = False DEFAULT_ASK_VAULT_PASS(default) = False DEFAULT_BECOME(default) = False DEFAULT_BECOME_ASK_PASS(default) = False DEFAULT_BECOME_EXE(default) = None DEFAULT_BECOME_FLAGS(default) = None DEFAULT_BECOME_METHOD(default) = sudo DEFAULT_BECOME_USER(default) = root DEFAULT_CACHE_PLUGIN_PATH(default) = ['/root/.ansible/plugins/cache', '/usr/share/ansible/plugins/cache'] DEFAULT_CALLBACK_PLUGIN_PATH(default) = ['/root/.ansible/plugins/callback', '/usr/share/ansible/plugins/callback'] DEFAULT_CLICONF_PLUGIN_PATH(default) = ['/root/.ansible/plugins/cliconf', '/usr/share/ansible/plugins/cliconf'] DEFAULT_CONNECTION_PLUGIN_PATH(default) = ['/root/.ansible/plugins/connection', '/usr/share/ansible/plugins/connection'] DEFAULT_DEBUG(default) = False DEFAULT_EXECUTABLE(default) = /bin/sh DEFAULT_FACT_PATH(default) = None DEFAULT_FILTER_PLUGIN_PATH(default) = ['/root/.ansible/plugins/filter', '/usr/share/ansible/plugins/filter'] DEFAULT_FORCE_HANDLERS(default) = False DEFAULT_FORKS(default) = 5 DEFAULT_GATHERING(default) = implicit DEFAULT_GATHER_SUBSET(default) = None DEFAULT_GATHER_TIMEOUT(default) = None DEFAULT_HASH_BEHAVIOUR(default) = replace DEFAULT_HOST_LIST(default) = ['/etc/ansible/hosts'] DEFAULT_HTTPAPI_PLUGIN_PATH(default) = ['/root/.ansible/plugins/httpapi', '/usr/share/ansible/plugins/httpapi'] DEFAULT_INTERNAL_POLL_INTERVAL(default) = 0.001 DEFAULT_INVENTORY_PLUGIN_PATH(default) = ['/root/.ansible/plugins/inventory', '/usr/share/ansible/plugins/inventory'] DEFAULT_JINJA2_EXTENSIONS(default) = [] DEFAULT_JINJA2_NATIVE(default) = False DEFAULT_KEEP_REMOTE_FILES(default) = False DEFAULT_LIBVIRT_LXC_NOSECLABEL(default) = False DEFAULT_LOAD_CALLBACK_PLUGINS(default) = False DEFAULT_LOCAL_TMP(default) = /root/.ansible/tmp/ansible-local-32dtrkzhuo DEFAULT_LOG_FILTER(default) = [] DEFAULT_LOG_PATH(default) = None DEFAULT_LOOKUP_PLUGIN_PATH(default) = ['/root/.ansible/plugins/lookup', '/usr/share/ansible/plugins/lookup'] DEFAULT_MANAGED_STR(default) = Ansible managed DEFAULT_MODULE_ARGS(default) = None DEFAULT_MODULE_COMPRESSION(default) = ZIP_DEFLATED DEFAULT_MODULE_NAME(default) = command DEFAULT_MODULE_PATH(default) = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] DEFAULT_MODULE_UTILS_PATH(default) = ['/root/.ansible/plugins/module_utils', '/usr/share/ansible/plugins/module_utils'] DEFAULT_NETCONF_PLUGIN_PATH(default) = ['/root/.ansible/plugins/netconf', '/usr/share/ansible/plugins/netconf'] DEFAULT_NO_LOG(default) = False DEFAULT_NO_TARGET_SYSLOG(default) = False DEFAULT_NULL_REPRESENTATION(default) = None DEFAULT_POLL_INTERVAL(default) = 15 DEFAULT_PRIVATE_KEY_FILE(default) = None DEFAULT_PRIVATE_ROLE_VARS(default) = False DEFAULT_REMOTE_PORT(default) = None DEFAULT_REMOTE_USER(default) = None DEFAULT_ROLES_PATH(default) = ['/root/.ansible/roles', '/usr/share/ansible/roles', '/etc/ansible/roles'] DEFAULT_SELINUX_SPECIAL_FS(default) = ['fuse', 'nfs', 'vboxsf', 'ramfs', '9p', 'vfat'] DEFAULT_STDOUT_CALLBACK(default) = default DEFAULT_STRATEGY(default) = linear DEFAULT_STRATEGY_PLUGIN_PATH(default) = ['/root/.ansible/plugins/strategy', '/usr/share/ansible/plugins/strategy'] DEFAULT_SU(default) = False DEFAULT_SYSLOG_FACILITY(default) = LOG_USER DEFAULT_TERMINAL_PLUGIN_PATH(default) = ['/root/.ansible/plugins/terminal', '/usr/share/ansible/plugins/terminal'] DEFAULT_TEST_PLUGIN_PATH(default) = ['/root/.ansible/plugins/test', '/usr/share/ansible/plugins/test'] DEFAULT_TIMEOUT(default) = 10 DEFAULT_TRANSPORT(default) = smart DEFAULT_UNDEFINED_VAR_BEHAVIOR(default) = True DEFAULT_VARS_PLUGIN_PATH(default) = ['/root/.ansible/plugins/vars', '/usr/share/ansible/plugins/vars'] DEFAULT_VAULT_ENCRYPT_IDENTITY(default) = None DEFAULT_VAULT_IDENTITY(default) = default DEFAULT_VAULT_IDENTITY_LIST(default) = [] DEFAULT_VAULT_ID_MATCH(default) = False DEFAULT_VAULT_PASSWORD_FILE(default) = None DEFAULT_VERBOSITY(default) = 0 DEPRECATION_WARNINGS(default) = True DEVEL_WARNING(default) = True DIFF_ALWAYS(default) = False DIFF_CONTEXT(default) = 3 DISPLAY_ARGS_TO_STDOUT(default) = False DISPLAY_SKIPPED_HOSTS(default) = True DOCSITE_ROOT_URL(default) = https://docs.ansible.com/ansible-core/ DOC_FRAGMENT_PLUGIN_PATH(default) = ['/root/.ansible/plugins/doc_fragments', '/usr/share/ansible/plugins/doc_fragments'] DUPLICATE_YAML_DICT_KEY(default) = warn ENABLE_TASK_DEBUGGER(default) = False ERROR_ON_MISSING_HANDLER(default) = True FACTS_MODULES(default) = ['smart'] GALAXY_CACHE_DIR(default) = /root/.ansible/galaxy_cache GALAXY_COLLECTION_SKELETON(default) = None GALAXY_COLLECTION_SKELETON_IGNORE(default) = ['^.git$', '^.*/.git_keep$'] GALAXY_DISABLE_GPG_VERIFY(default) = False GALAXY_DISPLAY_PROGRESS(default) = None GALAXY_GPG_KEYRING(default) = None GALAXY_IGNORE_CERTS(default) = None GALAXY_IGNORE_INVALID_SIGNATURE_STATUS_CODES(default) = None GALAXY_REQUIRED_VALID_SIGNATURE_COUNT(default) = 1 GALAXY_ROLE_SKELETON(default) = None GALAXY_ROLE_SKELETON_IGNORE(default) = ['^.git$', '^.*/.git_keep$'] GALAXY_SERVER(default) = https://galaxy.ansible.com GALAXY_SERVER_LIST(default) = None GALAXY_TOKEN_PATH(default) = /root/.ansible/galaxy_token HOST_KEY_CHECKING(default) = True HOST_PATTERN_MISMATCH(default) = warning INJECT_FACTS_AS_VARS(default) = True INTERPRETER_PYTHON(default) = auto INTERPRETER_PYTHON_FALLBACK(default) = ['python3.11', 'python3.10', 'python3.9', 'python3.8', 'python3.7', 'python3.6', 'python3.5', '/usr/bin/python3', '/usr/libexec/platform-python', 'python2.7', '/usr/bin/python', 'python'] INVALID_TASK_ATTRIBUTE_FAILED(default) = True INVENTORY_ANY_UNPARSED_IS_FAILED(default) = False INVENTORY_CACHE_ENABLED(default) = False INVENTORY_CACHE_PLUGIN(default) = None INVENTORY_CACHE_PLUGIN_CONNECTION(default) = None INVENTORY_CACHE_PLUGIN_PREFIX(default) = ansible_inventory_ INVENTORY_CACHE_TIMEOUT(default) = 3600 INVENTORY_ENABLED(default) = ['host_list', 'script', 'auto', 'yaml', 'ini', 'toml'] INVENTORY_EXPORT(default) = False INVENTORY_IGNORE_EXTS(default) = ('.pyc', '.pyo', '.swp', '.bak', '~', '.rpm', '.md', '.txt', '.rst', '.orig', '.ini', '.cfg', '.retry') INVENTORY_IGNORE_PATTERNS(default) = [] INVENTORY_UNPARSED_IS_FAILED(default) = False INVENTORY_UNPARSED_WARNING(default) = True JINJA2_NATIVE_WARNING(default) = True LOCALHOST_WARNING(default) = True MAX_FILE_SIZE_FOR_DIFF(default) = 104448 MODULE_IGNORE_EXTS(default) = ('.pyc', '.pyo', '.swp', '.bak', '~', '.rpm', '.md', '.txt', '.rst', '.yaml', '.yml', '.ini') NETCONF_SSH_CONFIG(default) = None NETWORK_GROUP_MODULES(default) = ['eos', 'nxos', 'ios', 'iosxr', 'junos', 'enos', 'ce', 'vyos', 'sros', 'dellos9', 'dellos10', 'dellos6', 'asa', 'aruba', 'aireos', 'bigip', 'ironware', 'onyx', 'netconf', 'exos', 'voss', 'slxos'] OLD_PLUGIN_CACHE_CLEARING(default) = False PARAMIKO_HOST_KEY_AUTO_ADD(default) = False PARAMIKO_LOOK_FOR_KEYS(default) = True PERSISTENT_COMMAND_TIMEOUT(default) = 30 PERSISTENT_CONNECT_RETRY_TIMEOUT(default) = 15 PERSISTENT_CONNECT_TIMEOUT(default) = 30 PERSISTENT_CONTROL_PATH_DIR(default) = /root/.ansible/pc PLAYBOOK_DIR(default) = None PLAYBOOK_VARS_ROOT(default) = top PLUGIN_FILTERS_CFG(default) = None PYTHON_MODULE_RLIMIT_NOFILE(default) = 0 RETRY_FILES_ENABLED(default) = False RETRY_FILES_SAVE_PATH(default) = None RUN_VARS_PLUGINS(default) = demand SHOW_CUSTOM_STATS(default) = False STRING_CONVERSION_ACTION(default) = warn STRING_TYPE_FILTERS(default) = ['string', 'to_json', 'to_nice_json', 'to_yaml', 'to_nice_yaml', 'ppretty', 'json'] SYSTEM_WARNINGS(default) = True TAGS_RUN(default) = [] TAGS_SKIP(default) = [] TASK_DEBUGGER_IGNORE_ERRORS(default) = True TASK_TIMEOUT(default) = 0 TRANSFORM_INVALID_GROUP_CHARS(default) = never USE_PERSISTENT_CONNECTIONS(default) = False VALIDATE_ACTION_GROUP_METADATA(default) = True VARIABLE_PLUGINS_ENABLED(default) = ['host_group_vars'] VARIABLE_PRECEDENCE(default) = ['all_inventory', 'groups_inventory', 'all_plugins_inventory', 'all_plugins_play', 'groups_plugins_inventory', 'groups_plugins_play'] VERBOSE_TO_STDERR(default) = False WIN_ASYNC_STARTUP_TIMEOUT(default) = 5 WORKER_SHUTDOWN_POLL_COUNT(default) = 0 WORKER_SHUTDOWN_POLL_DELAY(default) = 0.1 YAML_FILENAME_EXTENSIONS(default) = ['.yml', '.yaml', '.json'] BECOME: ====== runas: _____ become_flags(default) = become_pass(default) = None become_user(REQUIRED) = None su: __ become_exe(default) = su become_flags(default) = become_pass(default) = None become_user(default) = root prompt_l10n(default) = [] sudo: ____ become_exe(default) = sudo become_flags(default) = -H -S -n become_pass(default) = None become_user(default) = root CACHE: ===== jsonfile: ________ _prefix(default) = None _timeout(default) = 86400 _uri(REQUIRED) = None CALLBACK: ======== default: _______ check_mode_markers(default) = False display_failed_stderr(default) = False display_ok_hosts(default) = True display_skipped_hosts(default) = True pretty_results(default) = None result_format(default) = json show_custom_stats(default) = False show_per_host_start(default) = False show_task_path_on_failure(default) = False junit: _____ fail_on_change(default) = False fail_on_ignore(default) = False hide_task_arguments(default) = False include_setup_tasks_in_report(default) = True output_dir(default) = ~/.ansible.log replace_out_of_tree_path(default) = none task_class(default) = False task_relative_path(default) = none test_case_prefix(default) = minimal: _______ pretty_results(default) = None result_format(default) = json tree: ____ directory(default) = /root/.ansible/tree CLICONF: ======= CONNECTION: ========== local: _____ pipelining(default) = False paramiko_ssh: ____________ banner_timeout(default) = 30.0 host_key_auto_add(default) = None host_key_checking(default) = True look_for_keys(default) = True password(default) = None proxy_command(default) = pty(default) = True record_host_keys(default) = True remote_addr(default) = inventory_hostname remote_user(default) = None ssh_args(default) = ssh_common_args(default) = ssh_extra_args(default) = use_persistent_connections(default) = False use_rsa_sha2_algorithms(default) = True psrp: ____ auth(default) = negotiate ca_cert(default) = None cert_validation(default) = validate certificate_key_pem(default) = None certificate_pem(default) = None configuration_name(default) = Microsoft.PowerShell connection_timeout(default) = 30 credssp_auth_mechanism(default) = auto credssp_disable_tlsv1_2(default) = False credssp_minimum_version(default) = 2 ignore_proxy(default) = False max_envelope_size(default) = 153600 message_encryption(default) = auto negotiate_delegate(default) = None negotiate_hostname_override(default) = None negotiate_send_cbt(default) = True negotiate_service(default) = WSMAN operation_timeout(default) = 20 path(default) = wsman pipelining(default) = False port(default) = None protocol(default) = None proxy(default) = None read_timeout(default) = 30 reconnection_backoff(default) = 2 reconnection_retries(default) = 0 remote_addr(default) = inventory_hostname remote_password(default) = None remote_user(default) = None ssh: ___ control_path(default) = None control_path_dir(default) = ~/.ansible/cp host(default) = inventory_hostname host_key_checking(default) = True password(default) = None pipelining(default) = False pkcs11_provider(default) = port(default) = None private_key_file(default) = None reconnection_retries(default) = 0 remote_user(default) = None scp_executable(default) = scp scp_extra_args(default) = scp_if_ssh(default) = smart sftp_batch_mode(default) = True sftp_executable(default) = sftp sftp_extra_args(default) = ssh_args(default) = -C -o ControlMaster=auto -o ControlPersist=60s ssh_common_args(default) = ssh_executable(default) = ssh ssh_extra_args(default) = ssh_transfer_method(default) = None sshpass_prompt(default) = timeout(default) = 10 use_tty(default) = True winrm: _____ connection_timeout(default) = None kerberos_command(default) = kinit kerberos_mode(default) = None kinit_args(default) = None kinit_env_vars(default) = [] path(default) = /wsman pipelining(default) = False port(default) = 5986 remote_addr(default) = inventory_hostname remote_password(default) = None remote_user(default) = None scheme(default) = None transport(default) = None HTTPAPI: ======= INVENTORY: ========= constructed: ___________ compose(default) = {} groups(default) = {} keyed_groups(default) = [] leading_separator(default) = True plugin(REQUIRED) = None strict(default) = False use_extra_vars(default) = False use_vars_plugins(default) = False generator: _________ hosts(default) = None layers(default) = None plugin(REQUIRED) = None script: ______ always_show_stderr(default) = True yaml: ____ yaml_extensions(default) = ['.yaml', '.yml', '.json'] LOOKUP: ====== config: ______ _terms(REQUIRED) = None on_missing(default) = error plugin_name(default) = None plugin_type(default) = None csvfile: _______ col(default) = 1 default(default) = None delimiter(default) = TAB encoding(default) = utf-8 file(default) = ansible.csv dict: ____ _terms(REQUIRED) = None env: ___ _terms(REQUIRED) = None default(default) = file: ____ _terms(REQUIRED) = None lstrip(default) = False rstrip(default) = True fileglob: ________ _terms(REQUIRED) = None first_found: ___________ _terms(default) = None files(default) = [] paths(default) = [] skip(default) = False indexed_items: _____________ _terms(REQUIRED) = None ini: ___ _terms(REQUIRED) = None allow_no_value(default) = False case_sensitive(default) = False default(default) = encoding(default) = utf-8 file(default) = ansible.ini re(default) = False section(default) = global type(default) = ini items: _____ _terms(REQUIRED) = None lines: _____ _terms(REQUIRED) = None nested: ______ _raw(REQUIRED) = None password: ________ _terms(REQUIRED) = None chars(default) = ['ascii_letters', 'digits', '.,:-_'] encrypt(default) = None ident(default) = None length(default) = 20 seed(default) = None pipe: ____ _terms(REQUIRED) = None sequence: ________ count(default) = 0 end(default) = 0 format(default) = None start(default) = 0 stride(default) = None subelements: ___________ _terms(REQUIRED) = None skip_missing(default) = False template: ________ _terms(default) = None comment_end_string(default) = None comment_start_string(default) = None convert_data(default) = True jinja2_native(default) = False template_vars(default) = {} variable_end_string(default) = }} variable_start_string(default) = {{ together: ________ _terms(REQUIRED) = None unvault: _______ _terms(REQUIRED) = None url: ___ _terms(default) = None ca_path(default) = None ciphers(default) = None follow_redirects(default) = urllib2 force(default) = False force_basic_auth(default) = False headers(default) = {} http_agent(default) = ansible-httpget password(default) = None split_lines(default) = True timeout(default) = 10.0 unix_socket(default) = None unredirected_headers(default) = None use_gssapi(default) = False use_netrc(default) = True use_proxy(default) = True username(default) = None validate_certs(default) = True varnames: ________ _terms(REQUIRED) = None vars: ____ _terms(REQUIRED) = None default(default) = None NETCONF: ======= SHELL: ===== cmd: ___ async_dir(default) = %USERPROFILE%\.ansible_async environment(default) = [{}] remote_tmp(default) = %TEMP% set_module_language(default) = False powershell: __________ async_dir(default) = %USERPROFILE%\.ansible_async environment(default) = [{}] remote_tmp(default) = %TEMP% set_module_language(default) = False sh: __ admin_users(default) = ['root', 'toor'] async_dir(default) = ~/.ansible_async common_remote_group(default) = None environment(default) = [{}] remote_tmp(default) = ~/.ansible/tmp system_tmpdirs(default) = ['/var/tmp', '/tmp'] world_readable_temp(default) = False VARS: ==== host_group_vars: _______________ _valid_extensions(default) = ['.yml', '.yaml', '.json'] stage(default) = None $ ansible-config dump --only-changed -t all CONFIG_FILE() = None ```

OS / Environment

Gitlab runner : Alpine 3.18 playbook host : Ubuntu 22.04

Steps to Reproduce

    - name: `'https://emea.api.hvca.globalsign.com:8443/v2/login'
     ansible.builtin.uri:
        url: 'https://emea.api.hvca.globalsign.com:8443/v2/login'
        method: POST
        body:
          api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
          api_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        body_format: json
        headers:
          Content-Type: application/json;charset=utf-8
          Content-length: '1792'
        client_cert: /tmp/mtls.pem
        client_key: /tmp/mtls-nopwd.key
      register: result

### Expected Results

< HTTP/1.1 200 OK
< authorization: Bearer eyJhbGciOiJkaXIiLCJlb.......

{"access_token":"eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4R0....."}

### Actual Results

```console
TASK [https://emea.api.hvca.globalsign.com:8443/v2/login] **********************
fatal: [FRBKLSNI-0010.it.groupeavril.info]: FAILED! => {"changed": false, "elapsed": 30, "msg": "Status code was -1 and not [200]: Connection failure: The read operation timed out", "redirected": false, "status": -1, "url": "https://emea.api.hvca.globalsign.com:8443/v2/login"}
...ignoring
TASK [Debug Result] ************************************************************
ok: [FRBKLSNI-0010.it.groupeavril.info] => {
    "result": {
        "changed": false,
        "elapsed": 30,
        "failed": true,
        "msg": "Status code was -1 and not [200]: Connection failure: The read operation timed out",
        "redirected": false,
        "status": -1,
        "url": "https://emea.api.hvca.globalsign.com:8443/v2/login"
    }
}

OR

TASK [https://emea.api.hvca.globalsign.com:8443/v2/login] **********************
fatal: [FRBKLSNI-0010.it.groupeavril.info]: FAILED! => {"changed": false, "elapsed": 30, "msg": "Status code was -1 and not [200]: Connection failure: The read operation timed out", "redirected": false, "status": -1, "url": "https://emea.api.hvca.globalsign.com:8443/v2/login"}
...ignoring
TASK [Debug Result] ************************************************************
ok: [FRBKLSNI-0010.it.groupeavril.info] => {
    "result": {
        "changed": false,
        "elapsed": 30,
        "failed": true,
        "msg": "Status code was -1 and not [200]: Connection failure: The read operation timed out",
        "redirected": false,
        "status": -1,
        "url": "https://emea.api.hvca.globalsign.com:8443/v2/login"
    }
}

Code of Conduct

ansibot commented 8 months ago

Files identified in the description:

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

ansibot commented 8 months ago

@egl35720 ansible-core 2.14 is not supported and no longer receives bug fixes. Please test against one of the supported versions of ansible-core, preferably the most recent one, to see whether the bug has been fixed.

click here for bot help

egl35720 commented 8 months ago

Component Name ansible.builtin.uri

bcoca commented 8 months ago

please provide the full curl command use as well as -vvv output of the tasks

egl35720 commented 8 months ago

Hi Bcoca,

here is the curl command that works in ssh session (except my API_Key and my API_Secret I won't provide for security reason) :

curl -X POST -H 'Content-Type:application/json;charset=utf-8' -H 'Content-length:90' -d '{"api_key": "xxxxxxxxxx", "api_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }' https://emea.api.hvca.globalsign.com:8443/v2/login --cert /tmp/mtls.pem --key /tmp/mtls-nopwd.key -vvv

And its output (except "authorization" and "access_token" returned values I won't provide for security reason) : `Note: Unnecessary use of -X or --request, POST is already inferred.

If you want the exact command sent by ansible in the playbook task, I don't know how to display verbose output from my gitlab pipeline job that run the playbook :(

sivel commented 8 months ago

The first thing I would recommend is just removing the headers from the task. Let the module calculate the Content-Length and supply the Content-Type.

I cannot be sure, but it's possible that your content-length doesn't match the body that the module is actually sending

egl35720 commented 8 months ago

Hi Sivel,

I tried this :

--- - hosts: dockerengine

tasks: - name: 'BLOCK TEST LOGIN TO API' block: - name: 'Include variables' ansible.builtin.include_vars: file: vars/global.yml

- name: 'https://emea.api.hvca.globalsign.com:8443/v2/login' ansible.builtin.uri: url: 'https://emea.api.hvca.globalsign.com:8443/v2/login' method: POST body: api_key: xxxxxxxxxxxxxxx api_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx body_format: json # headers: # Content-Type: application/json;charset=utf-8 # Content-length: '1792' client_cert: /tmp/mtls.pem client_key: /tmp/mtls-nopwd.key ignore_errors: true register: result

- name: 'Debug Result' ansible.builtin.debug: var: result

and obtain this :

$ ansible-playbook -i ./inventories/staging.yml ./playbook.yml PLAY [dockerengine] **** TASK [Gathering Facts] ** ok: [xxxxxxx] TASK [Include variables] ok: [xxxxxxx] TASK [https://emea.api.hvca.globalsign.com:8443/v2/login] ** fatal: [xxxxx]: FAILED! => {"changed": false, "connection": "close", "content_length": "34", "content_type": "application/problem+json; charset=utf-8", "date": "Tue, 09 Jan 2024 16:43:09 GMT", "elapsed": 0, "msg": "Status code was 415 and not [200]: HTTP Error 415: Unsupported Media Type", "redirected": false, "status": 415, "url": "https://emea.api.hvca.globalsign.com:8443/v2/login"} ...ignoring TASK [Debug Result] **** ok: [xxxxxxx] => { "result": { "changed": false, "connection": "close", "content_length": "34", "content_type": "application/problem+json; charset=utf-8", "date": "Tue, 09 Jan 2024 16:43:09 GMT", "elapsed": 0, "failed": true, "msg": "Status code was 415 and not [200]: HTTP Error 415: Unsupported Media Type", "redirected": false, "status": 415, "url": "https://emea.api.hvca.globalsign.com:8443/v2/login" } } PLAY RECAP ***** xxxxxxx : ok=4 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=1

In Global Sign API's documentation headers key/values content-type and content-length are required : https://www.globalsign.com/en/resources/apis/api-documentation/globalsign_atlas_certificate_management_api.html#login_post

egl35720 commented 8 months ago

WTF, big Kiss @sivel !!! I just removed content-length from headers list and keep Content-type, NOW IT WORKS ! Alleluia !

That's a bit weird, because my initial code was working there's 2 week ago (before going on vacation) and this week it doesn't even with an initial commit that I am sure it worked !

OK thanks a lot for your help

egl35720 commented 8 months ago

WTF, big Kiss @sivel !!! I just removed content-length from headers list and keep Content-type, NOW IT WORKS ! Alleluia !

That's a bit weird, because my initial code was working there's 2 week ago (before going on vacation) and this week it doesn't even with an initial commit that I am sure it worked !

OK thanks a lot for your help