Merge pull request 'master' (#1) from dragonleo/role-goteleport:master into master

Reviewed-on: #1
This commit is contained in:
Lennard Brinkhaus 2023-09-02 14:53:01 +00:00
commit ff802476c9
6 changed files with 91 additions and 46 deletions

View File

@ -1,5 +1,9 @@
--- ---
teleport_version_check: true teleport_version_check: true
teleport_version: "12.0.2" teleport_version: "12.2.4"
teleport_dl_url: "https://cdn.teleport.dev/teleport-v{{ teleport_version }}-linux-{{ teleport_arch }}-bin" teleport_base_url_tar: "https://cdn.teleport.dev"
teleport_sha256_url: "https://get.gravitational.com/teleport-v{{ teleport_version }}-linux-{{ teleport_arch }}-bin" teleport_base_url_sha: "https://get.gravitational.com"
teleport_base_filename: teleport-v{{ teleport_version }}-linux-{{ teleport_arch }}-bin
teleport_dl_url: "{{ teleport_base_url_tar }}/{{ teleport_base_filename }}.tar.gz"
teleport_sha256_url: "{{ teleport_base_url_sha }}/{{ teleport_base_filename }}.tar.gz.sha256"
pid_file_telport: "/run/teleport.pid"

View File

@ -1,11 +1,24 @@
--- ---
- name: "Restart Teleport"
ansible.builtin.service:
name: teleport
state: restarted
when: ansible_service_mgr == "systemd"
- name: "Reload systemd" - name: "Reload systemd"
ansible.builtin.systemd: ansible.builtin.systemd:
daemon_reload: true daemon_reload: true
when: ansible_service_mgr == "systemd" when: ansible_service_mgr == "systemd"
- name: "Restart Teleport"
ansible.builtin.service:
name: teleport
state: restarted
async: 15
poll: 0
when: ansible_service_mgr == "systemd"
notify: "Check Teleport restart"
- name: "Check Teleport restart"
delegate_to: localhost
ansible.builtin.wait_for:
host: "{{ inventory_hostname }}"
port: "3022"
delay: 10
timeout: 30
state: started
msg: "Telport has restarted"

View File

@ -1,8 +1,14 @@
galaxy_info: galaxy_info:
author: your name role_name: update_goteleport
description: your role description namespace: dragse
company: your company (optional) author: Lennard Brinkhaus
description: This role update a binary installation of goteleport
company: DragSE
platforms:
- name: GenericLinux
versions:
- all
# If the issue tracker for your role is not on github, uncomment the # If the issue tracker for your role is not on github, uncomment the
# next line and provide a value # next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker # issue_tracker_url: http://example.com/issue/tracker
@ -14,9 +20,9 @@ galaxy_info:
# - GPL-3.0-only # - GPL-3.0-only
# - Apache-2.0 # - Apache-2.0
# - CC-BY-4.0 # - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc) license: None
min_ansible_version: 2.1 min_ansible_version: "2.1"
# If this a Container Enabled role, provide the minimum Ansible Container version. # If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version: # min_ansible_container_version:

View File

@ -1,55 +1,60 @@
--- ---
- block: - name: "Update goteleport block"
when: (not teleport_version_check|bool) or (teleport_active_version.stdout != teleport_version)
block:
- name: Download teleport archive - name: Download teleport archive
get_url: ansible.builtin.get_url:
url: "{{ teleport_dl_url }}.tar.gz" url: "{{ teleport_dl_url }}"
dest: "/tmp/teleport-{{ teleport_version }}-linux-{{ teleport_arch }}.tar.gz" dest: "/tmp/{{ teleport_base_filename }}.tar.gz"
checksum: "sha256:{{ teleport_sha256_url }}.tar.gz.sha256" checksum: "sha256:{{ teleport_sha256_url }}"
mode: "0755"
register: _download_archive register: _download_archive
until: _download_archive is succeeded until: _download_archive is succeeded
retries: 5 retries: 5
delay: 2 delay: 2
- name: create directory if they don't exist - name: Create directory if they don't exist
file: ansible.builtin.file:
path: "/tmp/teleport-{{ teleport_version }}" path: "/tmp/teleport-{{ teleport_version }}"
state: directory state: directory
owner: root owner: "root"
group: root group: "root"
mode: 0775 mode: "0775"
- name: Unpack Teleport Package - name: Unpack Teleport Package
unarchive: ansible.builtin.unarchive:
remote_src: yes remote_src: true
src: "/tmp/teleport-{{ teleport_version }}-linux-{{ teleport_arch }}.tar.gz" src: "/tmp/{{ teleport_base_filename }}.tar.gz"
dest: "/tmp/teleport-{{ teleport_version }}" dest: "/tmp/teleport-{{ teleport_version }}"
mode: 0755 mode: "0755"
owner: root owner: "root"
group: root group: "root"
- name: create directory if they don't exist - name: Create directory if they don't exist
file: ansible.builtin.file:
path: "/var/lib/teleport" path: "/var/lib/teleport"
state: directory state: directory
owner: root owner: "root"
group: root group: "root"
mode: 0775 mode: "0775"
- name: copy all binaries - name: Copy all binaries
copy: ansible.builtin.copy:
remote_src: true remote_src: true
src: "/tmp/teleport-{{ teleport_version }}/teleport/{{ item }}" src: "/tmp/teleport-{{ teleport_version }}/teleport/{{ item }}"
dest: "/usr/local/bin/{{ item }}" dest: "/usr/local/bin/{{ item }}"
owner: "root"
group: "root"
mode: "0755"
loop: loop:
- "tbot" - "tbot"
- "tctl" - "tctl"
- "tsh" - "tsh"
- "teleport" - "teleport"
notify:
- "Restart Teleport"
- name: copy teleport binary - name: "Clean Up Temporary Files"
copy: ansible.builtin.file:
remote_src: true state: absent
src: "/tmp/teleport-{{ teleport_version }}/teleport/teleport" path: /tmp/teleport-{{ teleport_version }}
dest: "/usr/local/bin/teleport"
notify: "Restart Teleport"
when: (not teleport_version_check|bool) or (teleport_active_version.stdout != teleport_version)

View File

@ -8,4 +8,20 @@
failed_when: false failed_when: false
when: teleport_version_check|bool when: teleport_version_check|bool
- include_tasks: "install.yml" - name: "Check if teleport pid file exist"
ansible.builtin.stat:
path: "{{ pid_file_telport }}"
register: pid_file_telport_state
- name: "Get Main PID of Teleport"
when: pid_file_teleport_state.stat.isdir is defined and not pid_file_teleport_state.stat.isdir
ansible.builtin.shell: "cat /run/teleport.pid"
args:
executable: /bin/bash
register: teleport_main_pid
changed_when: false
failed_when: false
- name: "Update goteleport"
ansible.builtin.include_tasks: "install.yml"

View File

@ -1,5 +1,6 @@
--- ---
- hosts: all - name: Test Playbook for testing goteleport
hosts: all
remote_user: root remote_user: root
roles: roles:
- role-goteleport - role-goteleport