Merge pull request #10 from sebthebert/dev_services

working disable/enable services
This commit is contained in:
Sebastien Thebert authored and GitHub committed 2022-10-29 13:18:35 +02:00
commit b6e262ded3
6 files changed
+69 -30

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
---
- name: Disable services
ansible.builtin.command: "pro disable {{ item }}"
become: yes
register: reg_pro_disable
when: item in ubuntu_pro_services
loop: "{{ disabled_services }}"
changed_when: reg_pro_disable.rc == 0
failed_when:
- reg_pro_disable.rc != 0
- ('is not currently enabled' not in reg_pro_disable.stdout_lines[0])
+11
View File
@@ -0,0 +1,11 @@
---
- name: Enable services
ansible.builtin.command: "pro enable {{ item }}"
become: yes
register: reg_pro_enable
when: item in ubuntu_pro_services
loop: "{{ enabled_services }}"
changed_when: reg_pro_enable.rc == 0
failed_when:
- reg_pro_enable.rc != 0
- ('is already enabled' not in reg_pro_enable.stdout_lines[1] and 'is not available for' not in reg_pro_enable.stdout_lines[1])
+14 -23
View File
@@ -1,29 +1,20 @@
---
- include_tasks: validate_ubuntu_lts_version.yml
- name: Include tasks 'validate_ubuntu_lts_version.yml'
include_tasks: validate_ubuntu_lts_version.yml
- name: Launch 'apt update'
ansible.builtin.apt:
update_cache: yes
become: yes
# - name: Include tasks 'requirements.yml'
# include_tasks: requirements.yml
- name: Launch 'apt upgrade'
ansible.builtin.apt:
upgrade: yes
become: yes
- name: Include tasks 'configure.yml'
include_tasks: configure.yml
- name: Install 'ubuntu-advantage-tools' package
ansible.builtin.apt:
name: ubuntu-advantage-tools
state: latest
become: yes
- name: Include tasks 'register.yml'
include_tasks: register.yml
- include_tasks: configure.yml
- name: Include tasks 'enable_services.yml'
include_tasks: enable_services.yml
when: enabled_services is defined
- name: Register this host on Ubuntu Pro (pro attach <token>)
ansible.builtin.command: "pro attach {{ ubuntu_pro_token }}"
become: yes
register: reg_pro_attach
- name: Print 'pro attach' command output
ansible.builtin.debug:
var: reg_pro_attach
- name: Include tasks 'disable_services.yml'
include_tasks: disable_services.yml
when: disabled_services is defined
+10
View File
@@ -0,0 +1,10 @@
---
- name: Register this host on Ubuntu Pro (pro attach <token>)
ansible.builtin.command: "pro attach {{ ubuntu_pro_token }}"
become: yes
register: reg_pro_attach
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
ansible.builtin.debug:
var: reg_pro_attach
+16
View File
@@ -0,0 +1,16 @@
---
- name: Launch 'apt update'
ansible.builtin.apt:
update_cache: yes
become: yes
- name: Launch 'apt upgrade'
ansible.builtin.apt:
upgrade: yes
become: yes
- name: Install 'ubuntu-advantage-tools' package
ansible.builtin.apt:
name: ubuntu-advantage-tools
state: latest
become: yes
+7 -7
View File
@@ -18,10 +18,10 @@ ubuntu_pro_lts_releases:
# 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
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