linux-system-roles / ssh

Ansible role for configuring ssh clients
https://linux-system-roles.github.io/ssh/
GNU Lesser General Public License v3.0
19 stars 17 forks source link

remove default value for __ssh_drop_in_name #82

Closed skwde closed 1 year ago

skwde commented 1 year ago

When

__ssh_drop_in_name: "00-ansible"

an empty default config is generated.

Currently

- name: Test
  hosts: rhel8
  gather_facts: false
  roles:
    - role: fedora.linux_system_roles.ssh
  become: true

reders an empty ssh_config.

That is because of

__ssh_drop_in_name: "00-ansible"

in the vars files.

Remove those lines fixes this.

richm commented 1 year ago

[citest]

richm commented 1 year ago

RHEL-9.3.0-20230403.57/ansible-2.14/(citool) fails - https://dl.fedoraproject.org/pub/alt/linuxsystemroles/logs/lsr-citool_ssh-82-7f17ed7_RHEL-9.3.0-20230403.57_20230405-220517/artifacts/summary.html

TASK [Download the custom configuration file drop-in] **************************
task path: /WORKDIR/dist-git-ssh-remove-default-drop-in-name-9pr8l69x/tests/tests_custom_drop_in.yml:31
Wednesday 05 April 2023  21:38:34 +0000 (0:00:03.310)       0:00:15.884 ******* 
fatal: [sut]: FAILED! => {
    "changed": false
}

MSG:

file not found: /tmp/ssh_config.d_00-ansible.conf
skwde commented 1 year ago

I am not really sure how I can run the tests locally without pushing all my tries upstream. Is there a way to run them locally?

richm commented 1 year ago

I am not really sure how I can run the tests locally without pushing all my tries upstream. Is there a way to run them locally?

See https://linux-system-roles.github.io/contribute.html "Using tox and tox-lsr" and "Running tests with tox-lsr and qemu" so that you can do something like tox -e qemu-ansible-core-2.14 -- --image-name centos-9 tests/tests_custom_drop_in.yml

richm commented 1 year ago

[citest]

Jakuje commented 1 year ago

I am not completely sure I understand the issue here. Calling the role without any parameters should not modify the system behavior and keep the system defaults if possible. That is achieved on the older systems by having defaults in place, which are regenerated in the main ssh_config. But when the drop-in directory exists and is supported, the simplest thing is to generate empty drop-in directory not to alter the system behavior and allow calling this role several times to create non-conflicting configuration snippets.

If I see right, what you do here is that you revert back to the modification of the main ssh_config by default on RHEL8+ and Fedora, which would be unexpected change of behavior.

Or do I miss something here?

skwde commented 1 year ago

@jakuje maybe then it is a misconception on my side, but how do I generate the default config to a custom location.

---
- name: Test
  hosts: rhel8
  gather_facts: false
  roles:
    - role: fedora.linux_system_roles.ssh
  become: true
  vars:
    ssh_config_file: ~/tests/ssh_config_rhel8

just yields

#
# Ansible managed
#
# system_role:ssh

which obviously is far from the default ssh_config on rhel8.

Jakuje commented 1 year ago

I think it should be done with ssh_skip_defaults: false:

---
- name: Test
  hosts: rhel8
  gather_facts: false
  roles:
    - role: fedora.linux_system_roles.ssh
  become: true
  vars:
    ssh_skip_defaults: false
    ssh_config_file: ~/tests/ssh_config_rhel8
skwde commented 1 year ago

@Jakuje thanks, that works!

I guess this now renders the entire pull request useless and there is no need to fix the failed tests.

Jakuje commented 1 year ago

Thanks for the patience! If this was not a clear from the available documentation, feel free to propose some documentation improvement. For me as I introduced this, it sounds clear, but there might be some gaps that only another pair of eyes will see.