Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Schöchlin <[email protected]>
  • Loading branch information
scoopex committed Dec 17, 2024
1 parent 8a070a4 commit df32310
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 56 deletions.
102 changes: 46 additions & 56 deletions environments/custom/roles/scs-sonic-minimal/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,61 +7,51 @@
update_password: always
password: "{{ operator_password_root }}"

- name: Create /etc/resolv.conf file
ansible.builtin.copy:
dest: /etc/resolv.conf
- name: Copy /etc/resolv.conf file
ansible.builtin.template:
src: resolv.conf.j2
dest: "/etc/resolv.conf"
owner: "root"
group: "root"
mode: 0644
owner: root
group: root
content: |
nameserver 10.10.23.254
nameserver 10.10.23.253
search mgmt.landscape.scs.community

#- name: Generate a unique temporary file path
# ansible.builtin.shell: mktemp /tmp/authorized_keys_XXXXXX
# register: temp_file_result
# delegate_to: localhost
# run_once: true
#- name: Set temp_file variable
# ansible.builtin.set_fact:
# temp_file: "{{ temp_file_result.stdout }}"
#- name: Create a temporary file to collect keys
# ansible.builtin.file:
# path: "{{ temp_file }}"
# state: touch
# mode: '0644'
# delegate_to: localhost
# run_once: true
#- name: Fetch public keys and append to the temp file
# ansible.builtin.uri:
# url: "https://github.com/{{ item }}.keys"
# return_content: yes
# register: key_fetch
# loop: "{{ operator_sonic_list }}"
# delegate_to: localhost
# run_once: true
#- name: Append keys to the temp file
# ansible.builtin.lineinfile:
# path: "{{ temp_file }}"
# line: "{{ item.content }}"
# create: yes
# state: present
# with_items: "{{ key_fetch.results }}"
# when: item.content is defined
# delegate_to: localhost
# run_once: true
#- name: Distribute the authorized_keys file to all hosts
# ansible.builtin.copy:
# src: "{{ temp_file }}"
# dest: /home/{{ ansible_user }}/.ssh/authorized_keys
# owner: "{{ ansible_user }}"
# group: "{{ ansible_user }}"
# mode: '0600'
#- name: Clean up temporary file
# ansible.builtin.file:
# path: "{{ temp_file }}"
# state: absent
# delegate_to: localhost
# run_once: true
#
- name: Generate a unique temporary file path
ansible.builtin.shell: mktemp /tmp/authorized_keys_XXXXXX
register: temp_file_result
delegate_to: localhost
run_once: true
become: false
- name: Set temp_file variable
ansible.builtin.set_fact:
temp_file: "{{ temp_file_result.stdout }}"
- name: Create a temporary file to collect keys
ansible.builtin.file:
path: "{{ temp_file }}"
state: touch
mode: '0644'
delegate_to: localhost
run_once: true
become: false
- name: Fetch public keys and append to the temp file
ansible.builtin.uri:
url: "https://github.com/{{ item }}.keys"
return_content: yes
register: key_fetch
loop: "{{ operator_sonic_list }}"
delegate_to: localhost
become: false
run_once: true
- name: "Copy /home/{{ ansible_user }}/.ssh/authorized_keys file"
ansible.builtin.template:
src: authorized_keys.j2
dest: "/home/{{ ansible_user }}/.ssh/authorized_keys"
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: '0600'
- name: Clean up temporary file
ansible.builtin.file:
path: "{{ temp_file }}"
state: absent
delegate_to: localhost
become: false
run_once: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# created by ansible
{% for item in resolvconf_nameserver %}
nameserver {{ item }}
{% endfor %}
search {{ resolvconf_search }}
1 change: 1 addition & 0 deletions inventory/group_vars/network_switches/10_access.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ansible_user: admin

operator_sonic_list:
- "scoopex"
Expand Down

0 comments on commit df32310

Please sign in to comment.