1
0
Fork 0

Initial base playbooks

Signed-off-by: Nis Wechselberg <enbewe@enbewe.de>
This commit is contained in:
Nis Wechselberg 2024-06-17 16:45:02 +02:00
parent 9c51597396
commit dd603044fc
Signed by: enbewe
GPG key ID: 7B25171F921B9E57
11 changed files with 305 additions and 0 deletions

40
playbooks/ubuntu_pro.yml Normal file
View file

@ -0,0 +1,40 @@
---
- name: 'Configure Ubuntu Pro subscription'
hosts: 'ubuntu_pro'
tasks:
- name: 'Install required software'
become: true
ansible.builtin.apt:
name: 'ubuntu-advantage-tools'
state: 'present'
- name: 'Register this host on Ubuntu Pro (pro attach <token>)'
become: true
ansible.builtin.command: 'pro attach {{ ubuntu_pro_token }}'
register: 'reg_pro_attach'
changed_when: 'reg_pro_attach.rc == 0'
failed_when:
- 'reg_pro_attach.rc != 0'
- '"This machine is already attached to" not in reg_pro_attach.stderr_lines[0]'
- name: 'Enable selected Ubuntu Pro services'
become: true
ansible.builtin.command: 'pro enable {{ item }}'
register: 'reg_pro_enable'
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]'
- '"is not available for" not in reg_pro_enable.stdout_lines[1]'
loop: '{{ ubuntu_pro_enabled_services }}'
- name: 'Disable selected Ubuntu Pro services'
become: true
ansible.builtin.command: 'pro disable {{ item }}'
register: 'reg_pro_disable'
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]'
loop: '{{ ubuntu_pro_disabled_services }}'