|
1 | 1 | --- |
2 | | -- block: |
3 | | - - name: Get stats of {{ _motd_sshd_config_file_path }} |
4 | | - stat: |
5 | | - path: "{{ _motd_sshd_config_file_path }}" |
6 | | - register: _motd_sshd_config_file_stat |
| 2 | +- include_tasks: configure_banner.yml |
7 | 3 |
|
8 | | - - name: Ensure PrintMotd is set to "no" in {{ _motd_sshd_config_file_path }} |
9 | | - lineinfile: |
10 | | - path: "{{ _motd_sshd_config_file_path }}" |
11 | | - regexp: "^PrintMotd " |
12 | | - line: PrintMotd no |
13 | | - when: _motd_sshd_config_file_stat.stat.exists |
14 | | - |
15 | | - - name: Comment out pam_motd in pam |
16 | | - replace: |
17 | | - path: "{{ item }}" |
18 | | - regexp: '^(session\s+optional\s+pam_motd.so\s+.*)' |
19 | | - replace: '# \1' |
20 | | - loop: |
21 | | - - "{{ _motd_pam_login_file_path }}" |
22 | | - - "{{ _motd_pam_sshd_file_path }}" |
| 4 | +- name: include_tasks disable_default_motd.yml if motd_disable_default_motd is True |
| 5 | + include_tasks: disable_default_motd.yml |
23 | 6 | when: motd_disable_default_motd|bool |
24 | 7 |
|
25 | | -- name: Apply template {{ motd_banner_template }} on {{ _motd_banner_file_path }} |
26 | | - copy: |
27 | | - content: "{{ motd_banner_template_prepend + _motd_banner_template_content + motd_banner_template_append }}" |
28 | | - dest: "{{ _motd_banner_file_path }}" |
29 | | - owner: root |
30 | | - group: root |
31 | | - mode: '0644' |
32 | | - when: motd_banner_template |
33 | | - |
34 | | -- name: Ensure line "Banner {{ _motd_banner_file_path }}" is {{ _motd_banner_state }} in {{ _motd_sshd_config_file_path }} |
35 | | - lineinfile: |
36 | | - path: "{{ _motd_sshd_config_file_path }}" |
37 | | - regexp: "^(#?)Banner " |
38 | | - line: Banner {{ _motd_banner_file_path }} |
39 | | - state: "{{ _motd_banner_state }}" |
40 | | - notify: Restart sshd |
41 | | - |
42 | | -- name: Apply template {{ motd_template }} on {{ _motd_file_path }} |
43 | | - copy: |
44 | | - content: "{{ motd_template_prepend + _motd_template_content + motd_template_append }}" |
45 | | - dest: "{{ _motd_file_path }}" |
46 | | - owner: root |
47 | | - group: root |
48 | | - mode: '0755' |
49 | | - tags: |
50 | | - - molecule-idempotence-notest |
51 | | - |
52 | | -- name: Add pam_exec {{ _motd_file_path }} in pam |
53 | | - lineinfile: |
54 | | - path: "{{ item }}" |
55 | | - line: session optional pam_exec.so type=open_session stdout {{ _motd_file_path }} |
56 | | - loop: |
57 | | - - "{{ _motd_pam_login_file_path }}" |
58 | | - - "{{ _motd_pam_sshd_file_path }}" |
| 8 | +- include_tasks: configure_motd.yml |
| 9 | +... |
0 commit comments