diff --git a/README.md b/README.md index 225dd44..6f3c6e8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Role Name ========= -A brief description of the role goes here. +Ensures cockpit is running Requirements ------------ @@ -30,7 +30,7 @@ Including an example of how to use your role (for instance, with variables passe License ------- -BSD +LGPL-3.0-or-later Author Information ------------------ diff --git a/meta/main.yml b/meta/main.yml index 227ad9c..931f95d 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,6 +1,6 @@ galaxy_info: - author: your name - description: your role description + author: Jason Rothstein + description: Ensures cockpit is installed, running, and functional company: your company (optional) # If the issue tracker for your role is not on github, uncomment the @@ -14,7 +14,7 @@ galaxy_info: # - GPL-3.0-only # - Apache-2.0 # - CC-BY-4.0 - license: license (GPL-2.0-or-later, MIT, etc) + license: LGPL-3.0-or-later min_ansible_version: 2.9 @@ -50,4 +50,4 @@ galaxy_info: dependencies: [] # List your role dependencies here, one per line. Be sure to remove the '[]' above, # if you add dependencies to this list. - \ No newline at end of file + diff --git a/tasks/main.yml b/tasks/main.yml index 8829754..f8019a5 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,2 +1,61 @@ --- -# tasks file for ensure_cockpit \ No newline at end of file +# tasks file for ensure_cockpit +- name: 'include variables' + when: + - ansible_system == 'Linux' + include_vars: + file: '{{ lookup("first_found", findme ) }}' + name: 'ensure_cockpit' + vars: + findme: + files: + - '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}.yml' + - '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}-default.yml' + - '{{ ansible_distribution }}-default.yml' + - '{{ ansible_os_family }}-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}.yml' + - '{{ ansible_os_family }}-{{ ansible_distribution_major_version }}-default.yml' + - '{{ ansible_os_family }}-default.yml' + - 'default.yml' + paths: + - '../vars/' + errors: 'ignore' +- name: 'package discovery' + when: + - ansible_system == 'Linux' + - packages is not defined + ansible.builtin.package_facts: +- name: 'ensure packages' + when: + - ansible_system == 'Linux' + - ensure_cockpit is defined + - ensure_cockpit.package_list is defined + - ensure_cockpit.package_list is iterable + - packages[item.name] is not defined + ansible.builtin.package: + name: '{{ item.name }}' + state: '{{ item.state }}' + loop: '{{ ensure_cockpit.package_list }}' + loop_control: + label: '{{ item.name }} will be {{ item.state }}' + notify: + - 'ensure_cockpit.package_facts' + - 'ensure_cockpit.service_facts' +- name: 'ensure services' + when: + - ansible_system == 'Linux' + - ensure_cockpit is defined + - ensure_cockpit.service_list is defined + - ensure_cockpit.service_list is iterable + ansible.builtin.service: + enabled: '{{ item.enabled }}' + name: '{{ item.name }}' + state: '{{ item.state }}' + loop: '{{ ensure_cockpit.service_list }}' + loop_control: + label: '{{ item.name }} will be {{ item.state }}' + notify: + - 'ensure_cockpit.package_facts' + - 'ensure_cockpit.service_facts' +- name: 'flush handlers' + meta: 'flush_handlers' + diff --git a/vars/Fedora-33.yml b/vars/Fedora-33.yml new file mode 100644 index 0000000..580f590 --- /dev/null +++ b/vars/Fedora-33.yml @@ -0,0 +1,32 @@ +--- +# vars file for ensure_cockpit +package_list: + - name: 'cockpit' + state: 'present' + - name: 'cockpit-bridge' + state: 'present' + - name: 'cockpit-dashboard' + state: 'present' + - name: 'cockpit-doc' + state: 'present' + - name: 'cockpit-kdump' + state: 'present' + - name: 'cockpit-networkmanager' + state: 'present' + - name: 'cockpit-packagekit' + state: 'present' + - name: 'cockpit-pcp' + state: 'present' + - name: 'cockpit-selinux' + state: 'present' + - name: 'cockpit-storaged' + state: 'present' + - name: 'cockpit-system' + state: 'present' + - name: 'cockpit-ws' + state: 'present' +service_list: + - name: 'cockpit.socket' + state: 'started' + enabled: 'yes' + diff --git a/vars/default.yml b/vars/default.yml new file mode 100644 index 0000000..3db30dc --- /dev/null +++ b/vars/default.yml @@ -0,0 +1,2 @@ +--- +# vars file for ensure_cockpit \ No newline at end of file