geerlingguy / geerlingguy/ansible-for-devops

Chapter 1, ssh config is being used

Open
#585 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
9.9k
Forks
3.8k
PR merge metrics
No merged PRs in 30d

Description

I'm sorry if this was already reported, but on page 6 the book mentions

> If you’re not using port 22 for SSH on this server, you will need to add it to the address, like www.example.com:2222, since Ansible defaults to port 22 and won’t get this value from your ssh config file

Which I believe is not true. With this inventory file
```ini
[test]
127.0.1.1
```
and this in `~/.ssh/config`
```
Host 127.*
port 2222
```
When I run `ansible -i inv test -m ping` I get
```
127.0.1.1 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: ssh: connect to host 127.0.1.1 port 2222: Connection refused",
"unreachable": true
}
```

One thing I noticed is that there is some sort of caching. If i remove the offending lines config from ssh config and use ansible it works as expected. After that if I re-add the two lines to ssh config ansible still uses the old, working port - [example](https://pastebin.com/eCwyAfn6)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Chapter 1 source for page 6 and review the quoted SSH configuration guidance. Reproduce the behavior using the shown inventory, ~/.ssh/config, and `ansible -i inv test -m ping`, including the reported caching sequence. Done means the chapter accurately describes whether Ansible uses SSH config and explains the observed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
ansible
Domain
devops, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.