diff --git a/README.md b/README.md index b7b1d19..31422ef 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Ansible Role : ubuntu_pro -An Ansible Role that registers host on [Ubuntu Pro](https://ubuntu.com/pro). +An Ansible Role that registers and configures host with [Ubuntu Pro](https://ubuntu.com/pro). ## Requirements @@ -10,11 +10,25 @@ Ubuntu Pro is only available for every **Ubuntu LTS releases from 16.04 LTS**. ## Roles Variables -The only mandatory variable for this role is `ubuntu_pro_token`. +The only mandatory variable is `ubuntu_pro_token`. -```yaml -ubuntu_pro_token: -``` +| Variable | Description | Type | Mandatory | Default Value | +|--------------------------------------------|----------------------------------|--------|-----------|---------------| +| `ubuntu_pro_token` | Ubuntu Pro token | String | YES | None | +|||||| +| `ubuntu_pro_config.http_proxy` | HTTP Proxy | String | NO | None | +| `ubuntu_pro_config.http_proxy` | HTTPS Proxy | String | NO | None | +| `ubuntu_pro_config.apt_http_proxy` | APT HTTP Proxy | String | NO | None | +| `ubuntu_pro_config.apt_https_proxy` | APT HTTPS Proxy | String | NO | None | +| `ubuntu_pro_config.ua_apt_http_proxy` | UA APT HTTP Proxy | String | NO | None | +| `ubuntu_pro_config.ua_apt_https_proxy` | UA APT HTTPS Proxy | String | NO | None | +| `ubuntu_pro_config.gloabl_apt_http_proxy` | Global APT HTTP Proxy | String | NO | None | +| `ubuntu_pro_config.global_apt_https_proxy` | Global APT HTTPS Proxy | String | NO | None | +| `ubuntu_pro_config.update_messaging_timer` | Update Messaging Timer | Int | NO | `21600` | +| `ubuntu_pro_config.update_status_timer` | Update Status Timer | Int | NO | `43200` | +| `ubuntu_pro_config.metering_timer` | Metering Timer | Int | NO | `14400` | + +You can find more information about `ubuntu_pro_config.*` variables on [Ubuntu Pro Client README](https://github.com/canonical/ubuntu-advantage-client#readme). ## Dependencies @@ -41,4 +55,4 @@ MIT / BSD ## Author Information -This role was created in October 2022 by [Sebastien Thebert](https://github.com/sebthebert). \ No newline at end of file +This role was created in October 2022 by [Sebastien Thebert](https://github.com/sebthebert). diff --git a/meta/argument_specs.yml b/meta/argument_specs.yml index 473904d..1427f32 100644 --- a/meta/argument_specs.yml +++ b/meta/argument_specs.yml @@ -11,3 +11,61 @@ argument_specs: - Ubuntu Pro token type: str required: true + ubuntu_pro_config.http_proxy: + description: + - HTTP Proxy + type: str + required: false + ubuntu_pro_config.https_proxy: + description: + - HTTPW Proxy + type: str + required: false + ubuntu_pro_config.apt_http_proxy: + description: + - apt HTTP Proxy + type: str + required: false + ubuntu_pro_config.apt_https_proxy: + description: + - apt HTTPs Proxy + type: str + required: false + ubuntu_pro_config.ua_apt_http_proxy: + description: + - ua apt HTTP Proxy + type: str + required: false + ubuntu_pro_config.ua_apt_https_proxy: + description: + - ua apt HTTPS Proxy + type: str + required: false + ubuntu_pro_config.global_apt_http_proxy: + description: + - global apt HTTP Proxy + type: str + required: false + ubuntu_pro_config.global_apt_https_proxy: + description: + - global apt HTTPS Proxy + type: str + required: false + ubuntu_pro_config.update_messaging_timer: + description: + - Update Messaging timer + type: int + required: false + default: 21600 + ubuntu_pro_config.update_status_timer: + description: + - Update Status timer + type: int + required: false + default: 43200 + ubuntu_pro_config.metering_timer: + description: + - Metering timer + type: int + required: false + default: 43200 diff --git a/tasks/configure.yml b/tasks/configure.yml new file mode 100644 index 0000000..14f0125 --- /dev/null +++ b/tasks/configure.yml @@ -0,0 +1,6 @@ +--- +- name: Configure proxies & timers for 'pro' client + ansible.builtin.command: "pro config {{ ('set ' + item.key + '=' + item.value if item.value else 'unset ' + item.key) }}" + loop: "{{ ubuntu_pro_config | dict2items }}" + when: ubuntu_pro_config is defined + become: yes diff --git a/tasks/main.yml b/tasks/main.yml index 651007b..10f0fb6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -11,6 +11,14 @@ upgrade: yes become: yes +- name: Install 'ubuntu-advantage-tools' package + ansible.builtin.apt: + name: ubuntu-advantage-tools + state: latest + become: yes + +- include_tasks: configure.yml + - name: Register this host on Ubuntu Pro (pro attach ) ansible.builtin.command: "pro attach {{ ubuntu_pro_token }}" become: yes diff --git a/vars/main.yml b/vars/main.yml index cdec506..d7768dd 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -4,3 +4,24 @@ ubuntu_pro_lts_releases: - "18.04" - "20.04" - "22.04" + +# ubuntu_pro_config: +# http_proxy: +# https_proxy: +# apt_http_proxy: +# apt_https_proxy: +# ua_apt_http_proxy: +# ua_apt_https_proxy: +# global_apt_http_proxy: +# global_apt_https_proxy: +# update_messaging_timer: 21600 +# update_status_timer: 43200 +# metering_timer: 14400 + +# ubuntu_pro_services: +# - 'cc-eal' # Common Criteria EAL2 +# - 'esm-infra' # Expanded Security Maintenance for Infrastructure +# - 'fips' +# - 'fips-updates' +# - 'livepatch' # Canonical Kernel Livepatch +# - 'usg' # Ubuntu Security Guide