ansible / ansible-modules-extras

Ansible extra modules - these modules ship with ansible
948 stars 1.46k forks source link

Pushover Hostname api.pushover.net:443 doesn't match #3677

Closed kkirsche closed 7 years ago

kkirsche commented 7 years ago
ISSUE TYPE
COMPONENT NAME

[Pushover](http://docs.ansible.com/ansible/pushover_module.html

ANSIBLE VERSION
ansible 2.2.0.0
  config file = /Users/kkirsche/git/yaml/mac_setup/ansible.cfg
  configured module search path = Default w/o overrides
CONFIGURATION
[defaults]
inventory: ./production
remote_user: kkirsche
remote_port: 22
forks: 20
pipelining: true
callback_whitelist: json
#stdout_callback: json
OS / ENVIRONMENT

macOS 10.12.1 -> macOS 10.12.1 (localhost) — N/A

SUMMARY

Running the pushover module results in the error:

hostname 'api.pushover.net:443' doesn't match either of '*.pushover.net', 'pushover.net'\", \"failed\": true, \"invocation
STEPS TO REPRODUCE

tasks/main.yml

---
# tasks file for ssh_config

- name: Notify that SSH Configuration is being changed
  pushover:
    msg: Mac SSH Configuration is being updated
    app_token: "{{ pushoverAppToken }}"
    user_key: "{{ pushoverUserKey }}"

- name: Create ~/.ssh if it doesn't exist
  file:
    path: "{{ ansible_env.HOME }}/.ssh"
    state: directory
    mode: "{{ ssh_directory_mode }}"

- name: Create ssh configuration file
  template:
    dest: "{{ ansible_env.HOME }}/.ssh/config"
    src: config.j2
    mode: "{{ ssh_config_mode }}"

templates/config.j2

{% for host in ssh_config_hosts %}
Host {{ ssh_config_hosts[host].host }}
{% if ssh_config_hosts[host].hostname is defined %}
Hostname {{ ssh_config_hosts[host].hostname }}
{% endif %}
{% if ssh_config_hosts[host].user is defined %}
User {{ ssh_config_hosts[host].user }}
{% endif %}
{% if ssh_config_hosts[host].port is defined %}
Port {{ ssh_config_hosts[host].port }}
{% endif %}
{% if ssh_config_hosts[host].proxy_command is defined %}
ProxyCommand {{ ssh_config_hosts[host].proxy_command }}
{% endif %}
{% if ssh_config_hosts[host].identity_file is defined %}
IdentityFile {{ ssh_config_hosts[host].identity_file }}
{% endif %}
{% if ssh_config_hosts[host].local_forward is defined %}
LocalForward {{ ssh_config_hosts[host].local_forward }}
{% endif %}

{% endfor %}

defaults/main.yml

---
# defaults file for ssh_config
ssh_directory_mode: 0700
ssh_config_mode: 0600

ssh_remote_user: kkirsche

ssh_config_hosts:
  googledns:
    host: gdns
    hostname: 8.8.8.8
    user: "{{ ssh_remote_user }}"
EXPECTED RESULTS

For it to send a pushover notification prior to running the configuration changes

ACTUAL RESULTS

The pushover notification failed with hostname 'api.pushover.net:443' doesn't match either of '*.pushover.net', 'pushover.net'\", \"failed\": true, \"invocation

___________________________________________________________
/ TASK [ssh_config : Notify that SSH Configuration is being \
\ changed]                                                  /
-----------------------------------------------------------
       \   ^__^
        \  (oo)\_______
           (__)\       )\/\
               ||----w |
               ||     ||

task path: /Users/kkirsche/git/yaml/mac_setup/roles/ssh_config/tasks/main.yml:4
Using module file /usr/local/Cellar/ansible/2.2.0.0_1/libexec/lib/python2.7/site-packages/ansible/modules/extras/notification/pushover.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: kkirsche
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1481047350.24-71608570119340 `" && echo ansible-tmp-1481047350.24-71608570119340="` echo $HOME/.ansible/tmp/ansible-tmp-1481047350.24-71608570119340 `" ) && sleep 0'
<127.0.0.1> PUT /var/folders/8y/pj9zz4b12r37490xnlqb7gb13tt57z/T/tmpO7biWl TO /Users/kkirsche/.ansible/tmp/ansible-tmp-1481047350.24-71608570119340/pushover.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /Users/kkirsche/.ansible/tmp/ansible-tmp-1481047350.24-71608570119340/ /Users/kkirsche/.ansible/tmp/ansible-tmp-1481047350.24-71608570119340/pushover.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /Users/kkirsche/.ansible/tmp/ansible-tmp-1481047350.24-71608570119340/pushover.py; rm -rf "/Users/kkirsche/.ansible/tmp/ansible-tmp-1481047350.24-71608570119340/" > /dev/null 2>&1 && sleep 0'
fatal: [127.0.0.1]: FAILED! => {
   "changed": false,
   "failed": true,
   "invocation": {
       "module_name": "pushover"
   },
   "module_stderr": "",
   "module_stdout": "\n{\"msg\": \"hostname 'api.pushover.net:443' doesn't match either of '*.pushover.net', 'pushover.net'\", \"failed\": true, \"invocation\": {\"module_args\": {\"msg\": \"Mac SSH Configuration is being updated\", \"user_key\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\", \"app_token\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\", \"pri\": \"0\"}}}\n\n{\"msg\": \"Unable to send msg via pushover\", \"failed\": true, \"invocation\": {\"module_args\": {\"msg\": \"Mac SSH Configuration is being updated\", \"user_key\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\", \"app_token\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\", \"pri\": \"0\"}}}\n",
   "msg": "MODULE FAILURE"
}
...ignoring
kkirsche commented 7 years ago

I've also validated the user and app tokens using httpie:

~/g/y/mac_setup ❯❯❯ http POST https://api.pushover.net/1/users/validate.json\?token={{ hidden }}\&user={{ hidden }}
HTTP/1.1 200 OK
Cache-Control: max-age=0, private, must-revalidate
Connection: keep-alive
Content-Type: application/json; charset=utf-8
Date: Tue, 06 Dec 2016 18:08:51 GMT
ETag: "bd42b670234bd2816679e361ec4c3497"
Strict-Transport-Security: max-age=31536000
Transfer-Encoding: chunked
X-Frame-Options: DENY
X-Request-Id: 63e343597646a0e7efea9db2336cfc42
X-Runtime: 0.009263
X-UA-Compatible: IE=Edge,chrome=1

{
    "devices": [
        "iPhone-6s"
    ],
    "group": 0,
    "request": "63e343597646a0e7efea9db2336cfc42",
    "status": 1
}
ansibot commented 7 years ago

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the repomerge page in the dev guide.