Skip to content

Commit b86affb

Browse files
authored
fix: Fixing an issue with ssh key generation for linux.base_objects (#3)
1 parent b0efada commit b86affb

File tree

3 files changed

+31
-17
lines changed

3 files changed

+31
-17
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,6 @@ Session.vim
102102

103103
## Temporary
104104
*~
105+
106+
artifacts/
107+
*.installed

src/firewheel_repo_linux/linux/INSTALL/tasks.yml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,38 @@
1010
state: directory
1111
loop: "{{ files }}"
1212

13+
- name: Create parent directories for SSH
14+
ansible.builtin.file:
15+
path: "{{ ssh_profile.path }}"
16+
state: directory
17+
mode: "0700"
18+
19+
- name: Check if combined_profiles.tgz exists
20+
ansible.builtin.stat:
21+
path: "{{ download_dir }}/combined_profiles.tgz"
22+
register: combined_profiles_stat
23+
1324
- name: Download and verify files
1425
ansible.builtin.get_url:
1526
url: "{{ item.url }}"
1627
dest: "{{ download_dir }}/{{ item.parent }}/{{ item.dest }}"
1728
checksum: "sha256:{{ item.sha256 }}"
1829
loop: "{{ files }}"
1930

20-
- name: Generate SSH key pair (if applicable)
21-
ansible.builtin.openssh_keypair:
31+
- name: Check if SSH private key already exists
32+
ansible.builtin.stat:
2233
path: "{{ ssh_profile.path }}/id_rsa"
23-
type: rsa
24-
size: 2048
25-
when: ssh_profile.ssh_keypair | default(false)
34+
register: ssh_key_status
35+
36+
- name: Generate SSH key pair using Bash (if not already present)
37+
ansible.builtin.command: >
38+
ssh-keygen -t rsa -b 2048 -f "{{ ssh_profile.path }}/id_rsa" -N ""
39+
when: not ssh_key_status.stat.exists
2640

2741
- name: Add public key to authorized_keys
2842
ansible.builtin.copy:
2943
content: "{{ lookup('file', ssh_profile.path + '/id_rsa.pub') }}"
3044
dest: "{{ ssh_profile.path }}/authorized_keys"
31-
when: ssh_profile.ssh_keypair | default(false)
3245

3346
- name: Create SSH config file
3447
ansible.builtin.copy:
@@ -38,22 +51,26 @@
3851
UserKnownHostsFile /dev/null
3952
ForwardX11Trusted yes
4053
dest: "{{ ssh_profile.path }}/config"
41-
when: ssh_profile.ssh_keypair | default(false)
4254

4355
- name: Set permissions for SSH files
4456
ansible.builtin.file:
4557
path: "{{ ssh_profile.path }}/{{ item.file }}"
4658
mode: "{{ item.mode }}"
4759
loop: "{{ ssh_profile.permissions }}"
48-
when: ssh_profile.ssh_keypair | default(false)
4960

5061
- name: Compress profiles into tarball
5162
ansible.builtin.archive:
5263
path:
5364
- "{{ download_dir }}/profiles"
54-
- "{{ ssh_profile.path }}"
5565
dest: "{{ download_dir }}/combined_profiles.tgz"
5666
format: gz
67+
when: not combined_profiles_stat.stat.exists
68+
69+
- name: Set permissions for combined_profiles.tgz
70+
ansible.builtin.file:
71+
path: "{{ download_dir }}/combined_profiles.tgz"
72+
mode: "0666"
73+
when: combined_profiles_stat.stat.exists
5774

5875
- name: Clean up temporary files
5976
ansible.builtin.file:

src/firewheel_repo_linux/linux/INSTALL/vars.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ files:
99
dest: ".bashrc"
1010
url: "https://github.com/sudonitesh/beautiful-bash/raw/4ad53ee9d1b0e2104e9dd77ae4f74e71262395d5/.bashrc"
1111
sha256: "19fca5072753f1bf8da1d4770d7dfe409c84e29ad21bbe92abbe37b7232df249"
12-
- parent: "profiles"
12+
- parent: "."
1313
dest: "tmux-cssh"
1414
url: "https://gitlab.com/peikk0/tmux-cssh/-/raw/a35957f7d9a0dbfd296b73dbb6f56ee4c193dc56/tmux-cssh"
1515
sha256: "cd44ed3321abc190a0a128b944b004857770e8ea18c03952e63a234cb3056098"
1616

1717
ssh_profile:
18-
path: "{{ download_dir }}/.ssh"
19-
ssh_keypair: true
18+
path: "{{ download_dir }}/profiles/.ssh"
2019
permissions:
2120
- file: "authorized_keys"
2221
mode: "0600"
@@ -26,8 +25,3 @@ ssh_profile:
2625
required_files:
2726
- destination: "{{ download_dir }}/combined_profiles.tgz"
2827
- destination: "{{ download_dir }}/tmux-cssh"
29-
- destination: "{{ mc_dir }}/vm_resources/chpasswd.sh"
30-
- destination: "{{ mc_dir }}/vm_resources/configure_ips.sh"
31-
- destination: "{{ mc_dir }}/vm_resources/set_hostname.sh"
32-
- destination: "{{ mc_dir }}/vm_resources/set_netplan_interfaces.sh"
33-
- destination: "{{ mc_dir }}/vm_resources/set_ulimit.sh"

0 commit comments

Comments
 (0)