Skip to content

Commit 9808bc4

Browse files
author
William Graef
committed
change olam passwordless ssh setup
1 parent f3d87c7 commit 9808bc4

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

olam/create_instance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@
310310
+ groups['server']|default([])
311311
312312
- name: Configure passwordless SSH
313-
ansible.builtin.include_tasks: "olam_passwordless_setup.yml"
313+
ansible.builtin.include_tasks: "passwordless_setup.yml"
314314
when: passwordless_ssh
315315

316316
- name: Install Oracle Linux Automation Engine
Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,53 @@
11
---
2-
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
2+
# Copyright (c) 2024 Oracle and/or its affiliates.
33
# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0.
44
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
55
# See LICENSE.TXT for details.
66

7-
- name: Generate ssh keypair for ol-control-node
7+
- name: Generate ssh keypair for user
88
community.crypto.openssh_keypair:
99
path: ~/.ssh/id_rsa
1010
size: 2048
11-
comment: olam ssh keypair
11+
comment: ol ssh keypair
1212
become: true
1313
become_user: "{{ username }}"
14-
when: inventory_hostname in groups['control']|default([])
1514

16-
- name: Fetch public key file from ol-control-node
15+
- name: Fetch public key file from server
1716
ansible.builtin.fetch:
1817
src: "~/.ssh/id_rsa.pub"
1918
dest: "buffer/{{ inventory_hostname }}-id_rsa.pub"
2019
flat: true
2120
become: true
2221
become_user: "{{ username }}"
23-
when: inventory_hostname in groups['control']|default([])
2422

25-
- name: Copy public key to ol-host
23+
- name: Copy public key to each destination
2624
ansible.posix.authorized_key:
27-
user: opc
25+
user: "{{ username }}"
2826
state: present
2927
key: "{{ lookup('file', 'buffer/{{ item }}-id_rsa.pub') }}"
30-
loop: "{{ groups['control'] | flatten(levels=1) }}"
28+
loop: "{{ groups['all'] | flatten(levels=1) }}"
3129
become: true
32-
when:
33-
- "'remote' in groups"
34-
- inventory_hostname in groups['remote']|default([])
3530

3631
- name: Print hostvars for groups
3732
ansible.builtin.debug:
3833
msg: "{{ hostvars[item] }}"
3934
loop: "{{ groups['all'] | flatten(levels=1) }}"
4035
when: debug_enabled
4136

37+
- name: Print vnc subnet_domain_name
38+
ansible.builtin.debug:
39+
var: my_subnet_domain_name
40+
when: debug_enabled
41+
4242
- name: Accept new ssh fingerprints
4343
ansible.builtin.shell: |
4444
ssh-keyscan -t ecdsa-sha2-nistp256 \
4545
{{ hostvars[item].ansible_hostname }},\
4646
{{ hostvars[item].ansible_default_ipv4.address }},\
4747
{{ hostvars[item].ansible_hostname + '.' + my_subnet_domain_name }} >> ~/.ssh/known_hosts
4848
with_items:
49-
- "{{ groups['remote'] }}"
49+
- "{{ groups['all'] }}"
5050
become: true
5151
become_user: "{{ username }}"
5252
register: result
5353
changed_when: result.rc == 0
54-
when:
55-
- "'remote' in groups"
56-
- inventory_hostname in groups['control']|default([])

0 commit comments

Comments
 (0)