Skip to content

Instantly share code, notes, and snippets.

@Diego91RA

Diego91RA/main.yml

Created Oct 9, 2020
Embed
What would you like to do?
HDB++ Ansible role
- name: Install packages
apt:
name:
- apt-transport-https
state: latest
force: yes
update_cache: yes
when:
deploy_hdb == 'yes'
- name: Install timescaledb
shell: |
rm -f /etc/apt/sources.list.d/pgdg.list \
&& sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -c -s`-pgdg main' >> /etc/apt/sources.list.d/pgdg.list" \
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& apt update \
&& rm -f /etc/apt/sources.list.d/timescaledb.list \
&& sh -c "echo 'deb https://packagecloud.io/timescale/timescaledb/debian/ `lsb_release -c -s` main' > /etc/apt/sources.list.d/timescaledb.list" \
&& wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | apt-key add - \
&& apt update \
&& apt install -y timescaledb-postgresql-12 postgresql-server-dev-12 \
&& timescaledb-tune --quiet --yes
when:
deploy_hdb == 'yes'
- name: Reconfigure postgres to login without host defining
lineinfile:
path: /etc/postgresql/12/main/pg_hba.conf
regexp: 'local\s+all\s+all\s+peer'
line: local all all md5
when:
deploy_hdb == 'yes'
- name: Clone libhdbpp
git:
repo: https://github.com/Diego91RA/libhdbpp.git
dest: {{hdb_dir}}/libhdbpp
become_user: tango
when:
deploy_hdb == 'yes'
- name: Build libhdbpp
shell: |
cd {{hdb_dir}}/libhdbpp/ \
&& mkdir -p build \
&& cd build \
&& cmake .. \
&& make \
&& sudo make install
become_user: tango
when:
deploy_hdb == 'yes'
- name: Clone libhdbpp-timescale
git:
repo: https://github.com/Diego91RA/libhdbpp-timescale.git
recursive: yes
dest: {{hdb_dir}}/libhdbpp-timescale
become_user: tango
when:
deploy_hdb == 'yes'
- name: Build libhdbpp-timescale
shell: |
cd {{hdb_dir}}/libhdbpp-timescale/ \
&& mkdir -p build \
&& cd build \
&& cmake -DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/postgresql/ .. \
&& make \
&& sudo make install
become_user: tango
when:
deploy_hdb == 'yes'
- name: Clone hdbpp-cm
git:
repo: https://github.com/Diego91RA/hdbpp-cm.git
dest: {{hdb_dir}}/hdbpp-cm
become_user: tango
when:
deploy_hdb == 'yes'
- name: Build hdbpp-cm
shell: |
cd {{hdb_dir}}/hdbpp-cm \
&& mkdir -p build \
&& cd build \
&& cmake .. \
&& make \
&& sudo make install
become_user: tango
when:
deploy_hdb == 'yes'
- name: Clone hdbpp-es
git:
repo: https://github.com/Diego91RA/hdbpp-es.git
dest: {{hdb_dir}}/hdbpp-es
become_user: tango
when:
deploy_hdb == 'yes'
- name: Build hdbpp-es
shell: |
cd {{hdb_dir}}/hdbpp-es \
&& mkdir -p build \
&& cd build \
&& cmake .. \
&& make \
&& sudo make install
become_user: tango
when:
deploy_hdb == 'yes'
- name: Install dependencies
apt:
name:
- maven
- python-psycopg2
- python3-psycopg2
- libpostgresql-jdbc-java
state: latest
update_cache: yes
when:
deploy_hdb == 'yes'
- name: Clone hdbpp-configurator
git:
repo: https://github.com/tango-controls-hdbpp/hdbpp-configurator
dest: {{hdb_dir}}/hdbpp-configurator
become_user: tango
when:
deploy_hdb == 'yes'
- name: Build hdbpp-configurator
shell: |
cd {{hdb_dir}}/hdbpp-configurator \
&& mvn package
become_user: tango
when:
deploy_hdb == 'yes'
- name: Clone hdbpp-viewer
git:
repo: https://github.com/tango-controls-hdbpp/hdbpp-viewer
dest: {{hdb_dir}}/hdbpp-viewer
become_user: tango
when:
deploy_hdb == 'yes'
- name: Build hdbpp-viewer
shell: |
cd {{hdb_dir}}/hdbpp-viewer \
&& mvn package
become_user: tango
when:
deploy_hdb == 'yes'
- name: Clone libhdbpp-extraction
git:
repo: https://github.com/tango-controls-hdbpp/libhdbpp-extraction-java
dest: {{hdb_dir}}/libhdbpp-extraction-java
become_user: tango
when:
deploy_hdb == 'yes'
- name: Build hdbpp-extractor
shell: |
cd {{hdb_dir}}/libhdbpp-extraction-java \
&& mvn package
become_user: tango
when:
deploy_hdb == 'yes'
- name: Create postgres user hdb_admin
postgresql_user:
name: hdb_admin
password: hdbpp
role_attr_flags: CREATEDB,CREATEROLE,SUPERUSER
become_user: postgres
when:
deploy_hdb == 'yes'
- name: Create HDB tables from file
shell: |
sudo service postgresql restart \
&& PGPASSWORD=hdbpp psql -U hdb_admin -f {{hdb_dir}}/libhdbpp-timescale/db-schema/schema.sql -d template1
become_user: tango
when:
deploy_hdb == 'yes'
- name: Create HDB tables from file
postgresql_query:
login_user: hdb_admin
login_password: hdbpp
db: hdb
path_to_script: {{hdb_dir}}/libhdbpp-timescale/db-schema/users.sql
become_user: tango
when:
deploy_hdb == 'yes'
- name: Find viewer jar
find:
paths: {{hdb_dir}}/hdbpp-viewer/target
patterns: "jhdbviewer*.jar"
register: viewer_matched
when:
deploy_hdb == 'yes'
- name: Find configurator jar
find:
paths: {{hdb_dir}}/hdbpp-configurator/target
patterns: "hdbpp-configurator*.jar"
register: configurator_matched
when:
deploy_hdb == 'yes'
- name: Find extraction jar
find:
paths: {{hdb_dir}}/libhdbpp-extraction-java/target
patterns: "libhdbpp-java*.jar"
register: extractor_matched
when:
deploy_hdb == 'yes'
- name: Copy all java applets to system folder
shell: |
cp {{ viewer_matched.files[0].path }} /usr/local/share/java/jhdbviewer.jar \
&& cp {{ configurator_matched.files[0].path }} /usr/local/share/java/hdbpp-configurator.jar \
&& cp {{ extractor_matched.files[0].path }} /usr/local/share/java/libhdbpp-java.jar \
&& cd /usr/local/share/java/ \
&& curl https://repo1.maven.org/maven2/org/python/jython/2.7.0/jython-2.7.0.jar --output jython.jar \
&& curl https://repo1.maven.org/maven2/com/toedter/jcalendar/1.4/jcalendar-1.4.jar --output jcalendar.jar \
when:
deploy_hdb == 'yes'
- name: Copy viewer and configurator execute scripts
copy: src={{ item.src }} dest={{ item.dest }} mode=755
with_items:
- { src: '{{playbook_dir}}/roles/hdb/files/hdb_configurator', dest: '{{hdb_dir}}/configurator' }
- { src: '{{playbook_dir}}/roles/hdb/files/hdb_viewer', dest: '{{hdb_dir}}/viewer' }
become_user: tango
when:
deploy_hdb == 'yes'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment