patternMinor
known_hosts module reports changed when nothing has changed
Viewed 0 times
reportsmodulehasnothingwhenknown_hostschanged
Problem
Why does my task report say that it has changed when nothing has changed?
```
TASK [Remove non existing host key from known_hosts file] *****
changed: [localhost]
TASK [Show known_hosts register] ****
ok: [localhost] => {
"reg_known_hosts": {
"changed": true,
"diff": {
"after": "192.168.122.230 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIzlnSq5ESxLgW0avvPk3j7zLV59hcAPkxrMNdnZMKP2\n",
"after_header": "/home/sxkx/.ssh/known_hosts",
"before": "192.168.122.230 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIzlnSq5ESxLgW0avvPk3j7zLV59hcAPkxrMNdnZMKP2\n",
"before_header": "/home/sxkx/.ssh/known_hosts"
},
"failed": false,
"gid": 1000,
"group": "sxkx",
"hash_host": false,
"key": "192.168.122.230 ssh-rsa ssh-rsa AAAAB3NzaC1yc2EAA
- hosts: localhost
become: false
gather_facts: false
tasks:
- name: Remove non existing host key from known_hosts file
known_hosts:
name: 192.168.122.230
key: 192.168.122.230 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCbi2hyrvpTRKC37NOm46n4zCPBb9r6cKk8BPrN2eppFu/0PJlB4D+nRI5epHzs5+1LhPkppbOGLC2VIRl3phMDQci3RIszhEZx4lAyX/HAkM+2zdNJlH2WWs3cbw804B4iqfCvy/Gch5ZXl4qEfpVqMURCr/XjaMQETzbjbfgOoyYxw8M/5Kq8VQy+DzqxNNzPi4ElcFQztxxrKDFPwuDplFdxw3YK+iQ4JHxlLWSfgtwsFhg7Z7uM8/efP7ocB23i2GmmG67yM/T/8uAld9t73V8icfe9WnRk2WVY69p4TzC3tMl2KmUDVm5AwvH+FNm/67E9t2inWHgKZacdOaOrgJ7SimPz0ILYDKd4hXg4whz3vdp21M/acjX3jA+fiwx6/GDIofKhyWOP3SwaiprqHZb+rWxerIOZx1IeuIRDZBH5Hjz7UlE5yg1xnqPXXzrFMj9rsKp9S5VB3HGGDfuOU7VymhZiTHIAuGM+weV6r2cOjn5HgdqkU6ABuchMAJvzaj9a3E07Rzk6h/lgWfy5VT/yl7DA7sM0/YSqKPJKgxbstoaOAZl35SDxAx978T0xlomIxaJUehRefK+G1GgPeLMmk0QtpX1dMH8bD4qvKGoLQG1qeJ4W4HrnoTsGLCxsN5/ek3rnqCekYOSiJ/q9+sZyhcLN1hwrDrrFK5fRUw==
state: absent
register: reg_known_hosts
- name: Show known_host register
debug:
var: reg_known_hosts
```
TASK [Remove non existing host key from known_hosts file] *****
changed: [localhost]
TASK [Show known_hosts register] ****
ok: [localhost] => {
"reg_known_hosts": {
"changed": true,
"diff": {
"after": "192.168.122.230 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIzlnSq5ESxLgW0avvPk3j7zLV59hcAPkxrMNdnZMKP2\n",
"after_header": "/home/sxkx/.ssh/known_hosts",
"before": "192.168.122.230 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIzlnSq5ESxLgW0avvPk3j7zLV59hcAPkxrMNdnZMKP2\n",
"before_header": "/home/sxkx/.ssh/known_hosts"
},
"failed": false,
"gid": 1000,
"group": "sxkx",
"hash_host": false,
"key": "192.168.122.230 ssh-rsa ssh-rsa AAAAB3NzaC1yc2EAA
Solution
It seems that the issue you've filed, Ansible Issue #78598 was noticed. It was possible to reproduce, got a small fix and an
Since further verification and testing is outstanding, you might be able to add the three proposed lines of code into your own
easyfix label.Since further verification and testing is outstanding, you might be able to add the three proposed lines of code into your own
known_host.py and test it. You could provide after testing an update on the Ansible Issue.Context
StackExchange DevOps Q#16448, answer score: 1
Revisions (0)
No revisions yet.