Skip to content

Commit

Permalink
Merge pull request #3 from sebthebert/dev_validate_ubuntu_lts_release
Browse files Browse the repository at this point in the history
Add 'Ubuntu LTS Release validation'
  • Loading branch information
sebthebert authored Oct 11, 2022
2 parents 7e37a23 + 6b1e5bb commit ddf3d70
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 ddf3d70

Please sign in to comment.