working disable/enable services

This commit is contained in:
Sebastien Thebert committed 2022-10-29 13:17:53 +02:00
1 parent 3de1cd1c9b
commit 342c00eda6
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