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:
|
vars_files:
|
||||||
- domainpwd.vault
|
- domainpwd.vault
|
||||||
roles:
|
roles:
|
||||||
- init
|
- { role: networkpackagemanager, when: 'ansible_local.checksum.needs_pkg_run == true or force_pkg_run == true' }
|
||||||
- base
|
- { role: init, when: 'ansible_local.checksum.needs_repo_run == true or force_repo_run == true' }
|
||||||
- custom
|
- { role: custom, when: 'ansible_local.checksum.needs_repo_run == true or force_repo_run == true' }
|
||||||
- domain
|
- { 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:
|
tags:
|
||||||
- domain
|
- domain
|
||||||
- join
|
- 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
|
# Managing installation/deletion of packages set with NetworkPackageManager
|
||||||
# within NethServer console
|
# within NethServer console
|
||||||
|
|
||||||
|
- name: Updating package cache.
|
||||||
|
apt: update_cache=yes cache_valid_time=180
|
||||||
|
|
||||||
- name: Installing packages for specific role from NetworkPackageManager
|
- name: Installing packages for specific role from NetworkPackageManager
|
||||||
apt:
|
apt:
|
||||||
name: '{{ item }}'
|
name: '{{ item }}'
|
||||||
@ -15,3 +18,7 @@
|
|||||||
state: absent
|
state: absent
|
||||||
purge: yes
|
purge: yes
|
||||||
with_items: "{{ delpkg }}"
|
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 }}')
|
r = requests.get("http://%s:3000/ansible_host" % '{{ ansible_local.domain.serverfqdn }}')
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
response = loads(r.text.encode('ascii', 'ignore'))
|
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()
|
live_pkg_hash = md5("".join(retval)).hexdigest()
|
||||||
|
|
||||||
if isfile(pkgver_file):
|
if isfile(pkgver_file):
|
||||||
@ -32,12 +32,22 @@ if isfile(pkgver_file):
|
|||||||
if isfile(repover_file):
|
if isfile(repover_file):
|
||||||
local_repo_hash = open(repover_file, 'r').read().strip()
|
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 = {
|
retval = {
|
||||||
'live_repover': live_repo_hash,
|
'needs_repo_run': repo_needed,
|
||||||
'repover': local_repo_hash,
|
'repover': live_repo_hash,
|
||||||
'repover_file': repover_file,
|
'repover_file': repover_file,
|
||||||
'live_pkgver': live_pkg_hash,
|
'needs_pkg_run': pkg_needed,
|
||||||
'pkgver': local_pkg_hash,
|
'pkgver': live_pkg_hash,
|
||||||
'pkgver_file': pkgver_file
|
'pkgver_file': pkgver_file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user