7 files changed
+92
-14
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
debug: false
|
||||||
|
state: present # possible values defined in meta/argument_specs.yml
|
||||||
+37
-2
@@ -6,6 +6,41 @@ argument_specs:
|
|||||||
- The main entry point just combines the repositories and packages
|
- The main entry point just combines the repositories and packages
|
||||||
entry points.
|
entry points.
|
||||||
options:
|
options:
|
||||||
|
debug:
|
||||||
|
description: Use debug module to display 'pro' command stdout/stderr
|
||||||
|
type: bool
|
||||||
|
default: false
|
||||||
|
disabled_services:
|
||||||
|
description: List of services to disable
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
|
choices:
|
||||||
|
- 'cc-eal' # Common Criteria EAL2
|
||||||
|
- 'esm-infra' # Expanded Security Maintenance for Infrastructure
|
||||||
|
- 'fips'
|
||||||
|
- 'fips-updates'
|
||||||
|
- 'livepatch' # Canonical Kernel Livepatch
|
||||||
|
- 'usg'
|
||||||
|
enabled_services:
|
||||||
|
description: List of services to enable
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
|
choices:
|
||||||
|
- 'cc-eal' # Common Criteria EAL2
|
||||||
|
- 'esm-infra' # Expanded Security Maintenance for Infrastructure
|
||||||
|
- 'fips'
|
||||||
|
- 'fips-updates'
|
||||||
|
- 'livepatch' # Canonical Kernel Livepatch
|
||||||
|
- 'usg'
|
||||||
|
state:
|
||||||
|
description: State of Ubuntu Pro installation
|
||||||
|
type: str
|
||||||
|
choices:
|
||||||
|
- absent
|
||||||
|
- attached
|
||||||
|
- detached
|
||||||
|
- present
|
||||||
|
default: present
|
||||||
ubuntu_pro_token:
|
ubuntu_pro_token:
|
||||||
description:
|
description:
|
||||||
- Ubuntu Pro token
|
- Ubuntu Pro token
|
||||||
@@ -18,7 +53,7 @@ argument_specs:
|
|||||||
required: false
|
required: false
|
||||||
ubuntu_pro_config.https_proxy:
|
ubuntu_pro_config.https_proxy:
|
||||||
description:
|
description:
|
||||||
- HTTPW Proxy
|
- HTTPS Proxy
|
||||||
type: str
|
type: str
|
||||||
required: false
|
required: false
|
||||||
ubuntu_pro_config.apt_http_proxy:
|
ubuntu_pro_config.apt_http_proxy:
|
||||||
@@ -28,7 +63,7 @@ argument_specs:
|
|||||||
required: false
|
required: false
|
||||||
ubuntu_pro_config.apt_https_proxy:
|
ubuntu_pro_config.apt_https_proxy:
|
||||||
description:
|
description:
|
||||||
- apt HTTPs Proxy
|
- apt HTTPS Proxy
|
||||||
type: str
|
type: str
|
||||||
required: false
|
required: false
|
||||||
ubuntu_pro_config.ua_apt_http_proxy:
|
ubuntu_pro_config.ua_apt_http_proxy:
|
||||||
|
|||||||
+16
-4
@@ -1,20 +1,32 @@
|
|||||||
---
|
---
|
||||||
- name: Include tasks 'validate_ubuntu_lts_version.yml'
|
- name: Include tasks 'validate_ubuntu_lts_version.yml'
|
||||||
include_tasks: validate_ubuntu_lts_version.yml
|
include_tasks: validate_ubuntu_lts_version.yml
|
||||||
|
when: state == 'present' or state == 'attached'
|
||||||
|
|
||||||
# - name: Include tasks 'requirements.yml'
|
- name: Include tasks 'requirements.yml'
|
||||||
# include_tasks: requirements.yml
|
include_tasks: requirements.yml
|
||||||
|
when: state == 'present' or state == 'attached'
|
||||||
|
|
||||||
- name: Include tasks 'configure.yml'
|
- name: Include tasks 'configure.yml'
|
||||||
include_tasks: configure.yml
|
include_tasks: configure.yml
|
||||||
|
when: state == 'present' or state == 'attached'
|
||||||
|
|
||||||
- name: Include tasks 'register.yml'
|
- name: Include tasks 'register.yml'
|
||||||
include_tasks: register.yml
|
include_tasks: register.yml
|
||||||
|
when: state == 'present' or state == 'attached'
|
||||||
|
|
||||||
- name: Include tasks 'enable_services.yml'
|
- name: Include tasks 'enable_services.yml'
|
||||||
include_tasks: enable_services.yml
|
include_tasks: enable_services.yml
|
||||||
when: enabled_services is defined
|
when: enabled_services is defined and (state == 'present' or state == 'attached')
|
||||||
|
|
||||||
- name: Include tasks 'disable_services.yml'
|
- name: Include tasks 'disable_services.yml'
|
||||||
include_tasks: disable_services.yml
|
include_tasks: disable_services.yml
|
||||||
when: disabled_services is defined
|
when: disabled_services is defined and (state == 'present' or state == 'attached')
|
||||||
|
|
||||||
|
- name: Include tasks 'unregister.yml'
|
||||||
|
include_tasks: unregister.yml
|
||||||
|
when: state == 'absent' or state == 'detached'
|
||||||
|
|
||||||
|
- name: Include tasks 'uninstall.yml'
|
||||||
|
include_tasks: uninstall.yml
|
||||||
|
when: state == 'absent'
|
||||||
@@ -3,8 +3,10 @@
|
|||||||
ansible.builtin.command: "pro attach {{ ubuntu_pro_token }}"
|
ansible.builtin.command: "pro attach {{ ubuntu_pro_token }}"
|
||||||
become: yes
|
become: yes
|
||||||
register: reg_pro_attach
|
register: reg_pro_attach
|
||||||
|
changed_when: reg_pro_attach.rc == 0
|
||||||
failed_when: (reg_pro_attach.rc != 0) and ('This machine is already attached to' not in reg_pro_attach.stderr_lines[0])
|
failed_when: (reg_pro_attach.rc != 0) and ('This machine is already attached to' not in reg_pro_attach.stderr_lines[0])
|
||||||
|
|
||||||
- name: Print 'pro attach' command output
|
- name: Print 'pro attach' command output
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: reg_pro_attach
|
var: reg_pro_attach
|
||||||
|
when: debug
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
---
|
---
|
||||||
- name: Launch 'apt update'
|
# - name: Launch 'apt update'
|
||||||
ansible.builtin.apt:
|
# ansible.builtin.apt:
|
||||||
update_cache: yes
|
# update_cache: yes
|
||||||
become: yes
|
# become: yes
|
||||||
|
|
||||||
- name: Launch 'apt upgrade'
|
# - name: Launch 'apt upgrade'
|
||||||
ansible.builtin.apt:
|
# ansible.builtin.apt:
|
||||||
upgrade: yes
|
# upgrade: yes
|
||||||
become: yes
|
# become: yes
|
||||||
|
|
||||||
- name: Install 'ubuntu-advantage-tools' package
|
- name: Install 'ubuntu-advantage-tools' package
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
- name: Uninstall 'ubuntu-advantage-tools' package
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: ubuntu-advantage-tools
|
||||||
|
state: absent
|
||||||
|
become: yes
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
- ansible.builtin.shell: "command pro"
|
||||||
|
register: reg_command_pro
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
pro_command_exists: "{{ (reg_command_pro.rc == 127) | ternary(false, true) }}"
|
||||||
|
|
||||||
|
- name: Unregister this host on Ubuntu Pro (pro detach)
|
||||||
|
ansible.builtin.command: "pro detach --assume-yes"
|
||||||
|
become: yes
|
||||||
|
register: reg_pro_detach
|
||||||
|
changed_when: reg_pro_detach.rc == 0
|
||||||
|
failed_when: (reg_pro_detach.rc != 0) and ('This machine is not attached to an Ubuntu Pro subscription.' not in reg_pro_detach.stderr_lines[0])
|
||||||
|
when: pro_command_exists
|
||||||
|
|
||||||
|
- name: Print 'pro detach' command output
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: reg_pro_detach
|
||||||
|
when: (debug and pro_command_exists)
|
||||||
Reference in new issue
Block a user