Cleanup of client tasks. It should run specific tasks only when changed.
This commit is contained in:
parent
a8627d0511
commit
eb1cb5801e
@ -5,7 +5,7 @@
|
||||
vars_files:
|
||||
- domainpwd.vault
|
||||
roles:
|
||||
- init
|
||||
- base
|
||||
- custom
|
||||
- domain
|
||||
- { role: networkpackagemanager, when: 'ansible_local.checksum.needs_pkg_run == true or force_pkg_run == true' }
|
||||
- { role: init, when: 'ansible_local.checksum.needs_repo_run == true or force_repo_run == true' }
|
||||
- { role: custom, when: 'ansible_local.checksum.needs_repo_run == true or force_repo_run == true' }
|
||||
- { role: domain, when: 'ansible_local.checksum.needs_repo_run == true or force_repo_run == true' }
|
||||
|
@ -1,3 +0,0 @@
|
||||
---
|
||||
dependencies:
|
||||
- { role: networkpackagemanager, tags: [ 'npm', 'networkpackagemanager' ] }
|
@ -1,3 +0,0 @@
|
||||
---
|
||||
depenedencies:
|
||||
- { role: networkpackagemanager, tags: [ 'npm', 'networkpackagemanager' ] }
|
@ -51,3 +51,7 @@
|
||||
tags:
|
||||
- domain
|
||||
- join
|
||||
|
||||
- name: Updating local version for repo
|
||||
shell: 'rm -f {{ ansible_local.checksum.repover_file }} && echo "{{ ansible_local.checksum.repover }}" > {{ ansible_local.checksum.repover_file }}'
|
||||
sudo: yes
|
||||
|
@ -2,6 +2,9 @@
|
||||
# Managing installation/deletion of packages set with NetworkPackageManager
|
||||
# within NethServer console
|
||||
|
||||
- name: Updating package cache.
|
||||
apt: update_cache=yes cache_valid_time=180
|
||||
|
||||
- name: Installing packages for specific role from NetworkPackageManager
|
||||
apt:
|
||||
name: '{{ item }}'
|
||||
@ -15,3 +18,7 @@
|
||||
state: absent
|
||||
purge: yes
|
||||
with_items: "{{ delpkg }}"
|
||||
|
||||
- name: Updating local hash for packages
|
||||
shell: 'rm -f {{ ansible_local.checksum.pkgver_file }} && echo "{{ ansible_local.checksum.pkgver }}" > {{ ansible_local.checksum.pkgver_file }}'
|
||||
sudo: yes
|
||||
|
@ -23,7 +23,7 @@ live_pkg_hash = ''
|
||||
r = requests.get("http://%s:3000/ansible_host" % '{{ ansible_local.domain.serverfqdn }}')
|
||||
if r.status_code == 200:
|
||||
response = loads(r.text.encode('ascii', 'ignore'))
|
||||
retval = sorted(response['addpkg']) + sorted(response['delpkg'])
|
||||
retval = sorted(response['addpkg']) + [ '-' ] + sorted(response['delpkg'])
|
||||
live_pkg_hash = md5("".join(retval)).hexdigest()
|
||||
|
||||
if isfile(pkgver_file):
|
||||
@ -32,12 +32,22 @@ if isfile(pkgver_file):
|
||||
if isfile(repover_file):
|
||||
local_repo_hash = open(repover_file, 'r').read().strip()
|
||||
|
||||
pkg_needed = False
|
||||
repo_needed = False
|
||||
|
||||
# Determining if run for packages and for configuraton has to be done
|
||||
if local_pkg_hash != live_pkg_hash:
|
||||
pkg_needed = True
|
||||
|
||||
if local_repo_hash != live_repo_hash:
|
||||
repo_needed = True
|
||||
|
||||
retval = {
|
||||
'live_repover': live_repo_hash,
|
||||
'repover': local_repo_hash,
|
||||
'needs_repo_run': repo_needed,
|
||||
'repover': live_repo_hash,
|
||||
'repover_file': repover_file,
|
||||
'live_pkgver': live_pkg_hash,
|
||||
'pkgver': local_pkg_hash,
|
||||
'needs_pkg_run': pkg_needed,
|
||||
'pkgver': live_pkg_hash,
|
||||
'pkgver_file': pkgver_file
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user