Skip to content

Commit

Permalink
Add 'Ubuntu LTS Release validation'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebthebert committed Oct 11, 2022
1 parent 651e52d commit 6b1e5bb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
1 change: 0 additions & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ galaxy_info:
galaxy_tags:
- system
- ubuntu
- ubuntu-pro

dependencies: []
9 changes: 6 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
- include_tasks: validate_ubuntu_lts_version.yml

- name: Launch 'apt update'
ansible.builtin.apt:
update_cache: yes
Expand All @@ -8,11 +10,12 @@
ansible.builtin.apt:
upgrade: yes
become: yes

- name: Register this host on Ubuntu Pro (pro attach <token>)
command: pro attach {{ ubuntu_pro_token }}
ansible.builtin.command: "pro attach {{ ubuntu_pro_token }}"
become: yes
register: reg_pro_attach

- debug:
- name: Print 'pro attach' command output
ansible.builtin.debug:
var: reg_pro_attach
18 changes: 18 additions & 0 deletions tasks/validate_ubuntu_lts_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Gather LSB Facts
ansible.builtin.setup:
filter: lsb

- name: Assert that Host Operating System is Ubuntu
ansible.builtin.assert:
that:
- ansible_facts.lsb.id == 'Ubuntu'
fail_msg: 'Host Operating System is NOT Ubuntu'
success_msg: 'Host Operating System is Ubuntu'

- name: Assert that Host Operating System is an Ubuntu LSB Release
ansible.builtin.assert:
that:
- ansible_facts.lsb.release in ubuntu_pro_lts_releases
fail_msg: 'Host Operating System is NOT an Ubuntu LSB Release'
success_msg: 'Host Operating System is an Ubuntu LSB Release'
6 changes: 6 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
ubuntu_pro_lts_releases:
- "16.04"
- "18.04"
- "20.04"
- "22.04"

0 comments on commit 6b1e5bb

Please sign in to comment.