diff --git a/meta/main.yml b/meta/main.yml index c160271..4e2375c 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -13,6 +13,5 @@ galaxy_info: galaxy_tags: - system - ubuntu - - ubuntu-pro dependencies: [] diff --git a/tasks/main.yml b/tasks/main.yml index ce74d53..651007b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,4 +1,6 @@ --- +- include_tasks: validate_ubuntu_lts_version.yml + - name: Launch 'apt update' ansible.builtin.apt: update_cache: yes @@ -8,11 +10,12 @@ ansible.builtin.apt: upgrade: yes become: yes - + - name: Register this host on Ubuntu Pro (pro attach ) - 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 diff --git a/tasks/validate_ubuntu_lts_version.yml b/tasks/validate_ubuntu_lts_version.yml new file mode 100644 index 0000000..75d137c --- /dev/null +++ b/tasks/validate_ubuntu_lts_version.yml @@ -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' diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..cdec506 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,6 @@ +--- +ubuntu_pro_lts_releases: + - "16.04" + - "18.04" + - "20.04" + - "22.04"