- separate out package update to its own role

- further refinements
This commit is contained in:
Pi
2019-07-25 08:54:41 -04:00
parent 3ef23484d8
commit f16d598797
7 changed files with 164 additions and 80 deletions

View File

@@ -2,12 +2,6 @@
- name: Include OS-specific variables
include_vars: "os_{{ ansible_lsb.id }}_{{ ansible_lsb.major_release }}.yml"
- name: Upgrade all packages to the latest version
become: true
apt:
upgrade: yes
update_cache: yes
tags: apt_upgrade
- name: Create directories
file:
path: "{{ item }}"

View File

@@ -1,4 +1,16 @@
---
- name: check if nDPI exists
stat:
path: "{{ ansible_user_dir }}/nDPI/src/lib/libndpi.so.2.9.0"
register: nDPI_installed
- name: check if ntopng built
stat:
path: "{{ ansible_user_dir }}/ntopng/ntopng"
register: ntopng_built
- name: check if ntopng installed
stat:
path: "/usr/local/bin/ntopng"
register: ntopng_installed
- name: Include OS-specific variables
include_vars: "os_{{ ansible_lsb.id }}_{{ ansible_lsb.major_release }}.yml"
- name: install package dependencies
@@ -10,49 +22,61 @@
git:
repo: https://github.com/ntop/nDPI.git
dest: "{{ ansible_user_dir }}/nDPI"
when: nDPI_installed.stat.exists == false
- name: clone ntopng
git:
repo: https://github.com/ntop/ntopng.git
dest: "{{ ansible_user_dir }}/ntopng"
when: ntopng_built.stat.exists == false
- name: run nDPI autogen.sh
command: "./autogen.sh"
args:
chdir: "{{ ansible_user_dir }}/nDPI"
when: nDPI_installed.stat.exists == false
- name: configure nDPI
command: "./configure --with-pic"
args:
chdir: "{{ ansible_user_dir }}/nDPI"
when: nDPI_installed.stat.exists == false
- name: build nDPI
command: "make -j 3"
args:
chdir: "{{ ansible_user_dir }}/nDPI"
when: nDPI_installed.stat.exists == false
- name: run ntopng autogen.sh
command: "./autogen.sh"
args:
chdir: "{{ ansible_user_dir }}/ntopng"
when: ntopng_built.stat.exists == false
- name: run ntopng configure
command: "./configure"
args:
chdir: "{{ ansible_user_dir }}/ntopng"
when: ntopng_built.stat.exists == false
- name: build ntopng
command: "make -j 3"
args:
chdir: "{{ ansible_user_dir }}/ntopng"
when: ntopng_built.stat.exists == false
- name: install
become: yes
command: "make install"
args:
chdir: "{{ ansible_user_dir }}/ntopng"
when: ntopng_installed.stat.exists == false
tags: test
- name: create ntopng group
become: yes
group:
name: ntopng
state: present
tags: test
- name: creaate ntopng user
become: yes
user:
name: ntopng
group: ntopng
tags: test
- name: create directories
become: yes
file:
@@ -64,6 +88,7 @@
- /var/nst/ntopng
- /usr/share/ntopng
- /etc/ntopng
tags: test
- name: copy files
become: yes
copy:
@@ -75,6 +100,7 @@
- { src: "{{ role_path }}/files/ntopng", dest: "/etc/default/ntopng" }
- { src: "{{ role_path }}/files/ntopng.conf", dest: "/etc/ntopng/ntopng.conf" }
- { src: "{{ role_path }}/files/ntopng.service", dest: "/etc/systemd/system/ntopng.service" }
tags: test
- name: reload systemd
become: true
systemd:

View File

@@ -11,3 +11,4 @@ ntopng_dependency_packages:
- libglib2.0-dev
- redis-server
- libmaxminddb-dev
- libjson-c-dev

View File

@@ -0,0 +1,7 @@
---
- name: Update all packages to the latest version
become: true
apt:
upgrade: yes
update_cache: yes
tags: apt_upgrade