Create additional SSH-keypair;Configure gitea
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Danny Bessems 2022-07-20 08:40:18 +02:00
parent 1746af9b9d
commit 261e91ee2e
3 changed files with 34 additions and 4 deletions

View File

@ -13,7 +13,7 @@
INSTALL_K3S_EXEC: 'server --cluster-init --disable local-storage' INSTALL_K3S_EXEC: 'server --cluster-init --disable local-storage'
when: ansible_facts.services['k3s.service'] is undefined when: ansible_facts.services['k3s.service'] is undefined
- name: Configure Traefik dashboard ingress - name: Configure traefik dashboard ingress
ansible.builtin.template: ansible.builtin.template:
src: ingressroute.j2 src: ingressroute.j2
dest: /var/lib/rancher/k3s/server/manifests/{{ _template.name }}-manifest.yaml dest: /var/lib/rancher/k3s/server/manifests/{{ _template.name }}-manifest.yaml
@ -201,16 +201,33 @@
- name: Retrieve existing gitea configuration - name: Retrieve existing gitea configuration
ansible.builtin.uri: ansible.builtin.uri:
# url: https://git.{{ vapp['metacluster.fqdn'] }}/api/v1/orgs # url: "{{ item }}"
url: https://git.{{ vapp['metacluster.fqdn'] }}/api/v1/repos/search url: https://git.{{ vapp['metacluster.fqdn'] }}/api/v1/repos/search
method: GET method: GET
register: gitea_existing_config register: gitea_existing_config
# loop:
# # - https://git.{{ vapp['metacluster.fqdn'] }}/api/v1/orgs
# - https://git.{{ vapp['metacluster.fqdn'] }}/api/v1/repos/search
# - https://git.{{ vapp['metacluster.fqdn'] }}/api/v1/user/keys
- debug: - debug:
var: gitea_existing_config var: gitea_existing_config
- block: - block:
- name: Register SSH public key
ansible.builtin.uri:
url: https://git.{{ vapp['metacluster.fqdn'] }}/api/v1/user/keys
method: POST
headers:
Authorization: token {{ gitea_api_token.json.sha1 }}
body:
key: "{{ gitops_sshkey.public_key }}"
read_only: false
title: GitOps
# Initial testing
ignore_errors: yes
- name: Create organization(s) - name: Create organization(s)
ansible.builtin.uri: ansible.builtin.uri:
url: https://git.{{ vapp['metacluster.fqdn'] }}/api/v1/orgs url: https://git.{{ vapp['metacluster.fqdn'] }}/api/v1/orgs

View File

@ -5,10 +5,12 @@
generate_ssh_key: yes generate_ssh_key: yes
ssh_key_bits: 2048 ssh_key_bits: 2048
ssh_key_file: .ssh/id_rsa ssh_key_file: .ssh/id_rsa
- name: Save root SSH publickey - name: Save root SSH publickey
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: /root/.ssh/authorized_keys path: /root/.ssh/authorized_keys
line: "{{ vapp['guestinfo.rootsshkey'] }}" line: "{{ vapp['guestinfo.rootsshkey'] }}"
- name: Disable SSH password authentication - name: Disable SSH password authentication
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config path: /etc/ssh/sshd_config
@ -16,8 +18,18 @@
line: "{{ item.line }}" line: "{{ item.line }}"
state: "{{ item.state }}" state: "{{ item.state }}"
loop: loop:
- { regex: '^#PasswordAuthentication', line: 'PasswordAuthentication no', state: present} - regex: '^#PasswordAuthentication'
- { regex: '^PasswordAuthentication yes', line: 'PasswordAuthentication yes', state: absent} line: 'PasswordAuthentication no'
state: present
- regex: '^PasswordAuthentication yes'
line: 'PasswordAuthentication yes'
state: absent
- name: Create dedicated SSH keypair
community.crypto.openssh_keypair:
path: /root/.ssh/git_rsa_id
register: gitops_sshkey
- name: Delete 'ubuntu' user - name: Delete 'ubuntu' user
ansible.builtin.user: ansible.builtin.user:
name: ubuntu name: ubuntu

View File

@ -122,6 +122,7 @@ dependencies:
ansible_galaxy_collections: ansible_galaxy_collections:
- ansible.posix - ansible.posix
- ansible.utils - ansible.utils
- community.crypto
- community.general - community.general
- kubernetes.core - kubernetes.core