Skip to content

Commit

Permalink
Match roles against host groups, tweak ssh server.
Browse files Browse the repository at this point in the history
Run roles against host groups instead of hostnames as a preparation
for extending the topologies.
Make sure ssh is not broken for ad-hoc added machines referencing
non-existent host keys.
  • Loading branch information
jakub-vavra-cz committed Aug 16, 2024
1 parent 2ebf336 commit fcbe4c2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/ansible/playbook_image_service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,40 @@
- firewall
- no_nscd

- hosts: master.ldap.test
- hosts: ldap
gather_facts: no
roles:
- ldap

- hosts: dc.samba.test
- hosts: samba
gather_facts: no
roles:
- samba

- hosts: master.ipa.test
- hosts: ipa
gather_facts: no
roles:
- ipa
- { role: passkey, when: ansible_distribution == "Ubuntu" or ansible_distribution == "Debian" }

- hosts: client.test
- hosts: client
gather_facts: no
roles:
- client
- { role: passkey, when: ansible_distribution == "Ubuntu" or ansible_distribution == "Debian" }
- { role: virtsmartcard, when: ansible_distribution != "Ubuntu" and ansible_distribution != "Debian" and virt_smartcard }

- hosts: nfs.test
- hosts: nfs
gather_facts: no
roles:
- nfs

- hosts: kdc.test
- hosts: kdc
gather_facts: no
roles:
- kdc

- hosts: master.keycloak.test
- hosts: keycloak
gather_facts: no
roles:
- keycloak
Expand Down
18 changes: 17 additions & 1 deletion src/ansible/roles/ssh_server/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
- name: Configure SSH daemon
- name: Check if we have pre-generated key
ansible.builtin.stat:
path: "/data/ssh-keys/hosts/{{ inventory_hostname }}.ecdsa_key"
register: stat_ecdsa_key

- name: Configure SSH daemon with pre-generated hostkey
template:
src: sshd.conf
dest: /etc/ssh/sshd_config.d
owner: root
group: root
mode: 0600
when: stat_ecdsa_key.stat.exists

- name: Configure SSH daemon without pre-generated hostkey
ansible.builtin.copy:
dest: /etc/ssh/sshd_config.d/sshd.conf
owner: root
group: root
mode: 0600
content: |
PermitRootLogin yes
when: not stat_ecdsa_key.stat.exists

- name: Start SSH daemon
service:
Expand Down

0 comments on commit fcbe4c2

Please sign in to comment.