From c2afd215e34beb69bf6e0665193ecf4d87d74e99 Mon Sep 17 00:00:00 2001 From: Nick White Date: Sat, 5 Jan 2019 12:16:04 +0000 Subject: tesstrainer role installs basic tesseract tools too, and only build and run ldconfig when necessary Use register variables and handlers to only run ldconfig and build tools when there's some need to do so. The tesseractor role is now only to be used by hosts that don't want training tools, hosts that want both should just use the tesstrainer role. --- hosts | 3 -- roles/tesseractor/handlers/main.yml | 3 ++ roles/tesseractor/tasks/ldlocal.yml | 4 +-- roles/tesseractor/tasks/tesseract.yml | 5 ++- roles/tesstrainer/handlers/main.yml | 3 ++ roles/tesstrainer/tasks/ldlocal.yml | 4 +-- roles/tesstrainer/tasks/main.yml | 2 +- roles/tesstrainer/tasks/tesseract.yml | 54 ++++++++++++++++++++++++++++++++ roles/tesstrainer/tasks/tesstraining.yml | 47 --------------------------- site.yml | 2 +- 10 files changed, 68 insertions(+), 59 deletions(-) create mode 100644 roles/tesseractor/handlers/main.yml create mode 100644 roles/tesstrainer/handlers/main.yml create mode 100644 roles/tesstrainer/tasks/tesseract.yml delete mode 100644 roles/tesstrainer/tasks/tesstraining.yml diff --git a/hosts b/hosts index b32a2bc..b994a4b 100644 --- a/hosts +++ b/hosts @@ -1,8 +1,5 @@ [servers] devami -[tesseractors] -devami - [tesstrainers] devami diff --git a/roles/tesseractor/handlers/main.yml b/roles/tesseractor/handlers/main.yml new file mode 100644 index 0000000..12df781 --- /dev/null +++ b/roles/tesseractor/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: update ld.so + command: /sbin/ldconfig diff --git a/roles/tesseractor/tasks/ldlocal.yml b/roles/tesseractor/tasks/ldlocal.yml index e817d85..2fd5fac 100644 --- a/roles/tesseractor/tasks/ldlocal.yml +++ b/roles/tesseractor/tasks/ldlocal.yml @@ -6,6 +6,4 @@ dest: /etc/ld.so.conf.d/locallib.conf create: true line: /usr/local/lib - -- name: Update ld.so cache - command: /sbin/ldconfig + notify: update ld.so diff --git a/roles/tesseractor/tasks/tesseract.yml b/roles/tesseractor/tasks/tesseract.yml index 74c9076..e63cfee 100644 --- a/roles/tesseractor/tasks/tesseract.yml +++ b/roles/tesseractor/tasks/tesseract.yml @@ -22,12 +22,13 @@ dest: /home/ec2-user/src/leptonica version: addinstall depth: 1 - force: yes + register: leptclone - name: Build leptonica command: make -f makefile.static SHARED=yes install args: chdir: /home/ec2-user/src/leptonica/src + when: leptclone.changed - name: Clone tesseract repository git: @@ -35,6 +36,8 @@ dest: /home/ec2-user/src/tesseract version: amibuild depth: 1 + register: tessclone - name: Build and install tesseract make: chdir=/home/ec2-user/src/tesseract/simplemake target=install + when: tessclone.changed diff --git a/roles/tesstrainer/handlers/main.yml b/roles/tesstrainer/handlers/main.yml new file mode 100644 index 0000000..12df781 --- /dev/null +++ b/roles/tesstrainer/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: update ld.so + command: /sbin/ldconfig diff --git a/roles/tesstrainer/tasks/ldlocal.yml b/roles/tesstrainer/tasks/ldlocal.yml index e817d85..2fd5fac 100644 --- a/roles/tesstrainer/tasks/ldlocal.yml +++ b/roles/tesstrainer/tasks/ldlocal.yml @@ -6,6 +6,4 @@ dest: /etc/ld.so.conf.d/locallib.conf create: true line: /usr/local/lib - -- name: Update ld.so cache - command: /sbin/ldconfig + notify: update ld.so diff --git a/roles/tesstrainer/tasks/main.yml b/roles/tesstrainer/tasks/main.yml index e1245fd..33d6a30 100644 --- a/roles/tesstrainer/tasks/main.yml +++ b/roles/tesstrainer/tasks/main.yml @@ -1,3 +1,3 @@ --- -- include: tesstraining.yml +- include: tesseract.yml - include: ldlocal.yml diff --git a/roles/tesstrainer/tasks/tesseract.yml b/roles/tesstrainer/tasks/tesseract.yml new file mode 100644 index 0000000..0be3380 --- /dev/null +++ b/roles/tesstrainer/tasks/tesseract.yml @@ -0,0 +1,54 @@ +--- +# Installs tesseract + +- name: Install tesseract dependencies + package: name={{ item }} state=present + with_items: + - gcc-c++ + - make + - libpng12-devel + - libjpeg-turbo-devel + - libtiff-devel + - zlib-devel + +- name: Install tesseract training dependencies + package: name={{ item }} state=present + with_items: + - libicu-devel + - pango-devel + - cairo-devel + +- name: Install extra tesseract development dependencies + package: name={{ item }} state=present + with_items: + - git + +- name: Clone leptonica repository + git: + repo: https://github.com/nickjwhite/leptonica + dest: /home/ec2-user/src/leptonica + version: addinstall + depth: 1 + register: leptclone + +- name: Build leptonica + command: make -f makefile.static SHARED=yes install + args: + chdir: /home/ec2-user/src/leptonica/src + when: leptclone.changed + +- name: Clone tesseract repository + git: + repo: https://github.com/nickjwhite/tesseract + dest: /home/ec2-user/src/tesseract + version: amibuild + depth: 1 + register: tessclone + +- name: Build and install tesseract + make: chdir=/home/ec2-user/src/tesseract/simplemake target=install + when: tessclone.changed + +- name: Build and install tesseract training tools + make: chdir=/home/ec2-user/src/tesseract/simplemake target=install-training + when: tessclone.changed diff --git a/roles/tesstrainer/tasks/tesstraining.yml b/roles/tesstrainer/tasks/tesstraining.yml deleted file mode 100644 index 0bcbf7a..0000000 --- a/roles/tesstrainer/tasks/tesstraining.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -# Installs tesseract - -- name: Install tesseract dependencies - package: name={{ item }} state=present - with_items: - - gcc-c++ - - make - - libpng12-devel - - libjpeg-turbo-devel - - libtiff-devel - - zlib-devel - -- name: Install tesseract training dependencies - package: name={{ item }} state=present - with_items: - - libicu-devel - - pango-devel - - cairo-devel - -- name: Install extra tesseract development dependencies - package: name={{ item }} state=present - with_items: - - git - -- name: Clone leptonica repository - git: - repo: https://github.com/nickjwhite/leptonica - dest: /home/ec2-user/src/leptonica - version: addinstall - depth: 1 - force: yes - -- name: Build leptonica - command: make -f makefile.static SHARED=yes install - args: - chdir: /home/ec2-user/src/leptonica/src - -- name: Clone tesseract repository - git: - repo: https://github.com/nickjwhite/tesseract - dest: /home/ec2-user/src/tesseract - version: amibuild - depth: 1 - -- name: Build and install tesseract training tools - make: chdir=/home/ec2-user/src/tesseract/simplemake target=install-training diff --git a/site.yml b/site.yml index 1bdc22d..9e0f7b9 100644 --- a/site.yml +++ b/site.yml @@ -14,7 +14,7 @@ roles: - tesseractor -- name: Configure servers for Tesseract Training +- name: Configure servers for Tesseract with training tools hosts: tesstrainers become: yes -- cgit v1.2.1-24-ge1ad