forked from linux-system-roles/ssh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests_all_options.yml
More file actions
128 lines (111 loc) · 4.01 KB
/
tests_all_options.yml
File metadata and controls
128 lines (111 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
---
- name: Test we can handle all configuration options documented in manual page
hosts: all
vars:
ssh_c: {}
pkg_mgr: "{{ (ansible_facts['distribution_version'] | int > 7) |
ternary('dnf', 'yum') }}"
tasks:
- name: Ubuntu and RHEL6 containers are minified, missing manual pages
meta: end_host
when:
- ansible_facts['distribution'] == 'Ubuntu' or
(ansible_facts['distribution'] in ['CentOS', 'RedHat'] and
ansible_facts['distribution_version'] | int < 7)
- name: Define common variables
set_fact:
ssh_test_package: openssh-clients
- name: Define specific variables
set_fact:
ssh_test_package: openssh-client
when: >
ansible_facts['os_family'] not in ['RedHat', 'Suse']
- name: Determine if system is ostree and set flag
when: not __ssh_is_ostree is defined
block:
- name: Check if system is ostree
stat:
path: /run/ostree-booted
register: __ostree_booted_stat
- name: Set flag to indicate system is ostree
set_fact:
__ssh_is_ostree: "{{ __ostree_booted_stat.stat.exists }}"
- name: Enable installation of manual pages on Fedora/RHEL
ansible.builtin.lineinfile:
line: tsflags=nodocs
path: "{{ '/etc/dnf/dnf.conf'
if ansible_facts['distribution_version'] | int > 7
else '/etc/yum.conf' }}"
state: absent
register: __ssh_nodocs
when:
- ansible_facts['os_family'] == "RedHat"
- name: Reinstall manual pages for openssh-clients on RHEL
ansible.builtin.command: "{{ pkg_mgr }} reinstall -y openssh-clients"
when:
- __ssh_nodocs is changed
- ansible_facts['os_family'] == "RedHat"
- not __ssh_is_ostree | bool
changed_when: true
- name: Make sure manual pages, gawk and bash are installed
package:
name:
- "{{ (ansible_facts['os_family'] == 'RedHat') |
ternary('man-db', 'man') }}"
- gawk
- bash
- "{{ ssh_test_package }}"
state: present
use: "{{ (__ssh_is_ostree | d(false)) |
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
- name: Check if ssh_config man page is available
command: man -w ssh_config
register: __ssh_man_check
failed_when: false
changed_when: false
- name: Skip if ssh_config man page is not available
meta: end_host
when: __ssh_man_check.rc != 0
- name: Get list of options from manual page
shell: >-
set -o pipefail && man ssh_config \
| grep -o '^\( \| \)[A-Z][A-Za-z0-9]*\(.\| \)' \
| grep -v "[A-Za-z0-9] $" | grep -v "[^A-Za-z0-9 ]$" \
| awk '{ print $1 }' \
| grep -v '^$' | grep -v \
"^\(A\|Match\|Host\|OpenSSH\|The\|\Theo\|Tatu\|Unless\|Since\|Arguments\|Note\|Tag\)$"
args:
executable: /bin/bash
register: ssh_options
changed_when: false
- name: Show ssh_options
debug:
var: ssh_options.stdout_lines
- name: Construct the configuration list
set_fact:
ssh_c: "{{ ssh_c | combine({item: 'yes'}) }}"
loop:
"{{ ssh_options.stdout_lines }}"
- name: Run role
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__ssh_supports_validate: false
ssh_config_file: /etc/test_ssh_config
ssh:
"{{ ssh_c }}"
when: not __bootc_validation | d(false)
- name: Create QEMU deployment during bootc end-to-end test
delegate_to: localhost
command: "{{ lsr_scriptdir }}/bootc-buildah-qcow.sh {{ ansible_host }}"
changed_when: true
when: ansible_connection == "buildah"
- name: Download the configuration file
slurp:
src: /etc/test_ssh_config
register: config
- name: Verify the options are in the file
assert:
that:
- item ~ ' yes' in config.content | b64decode
loop:
"{{ ssh_options.stdout_lines }}"