--- - name: install jre apt: name=openjdk-21-jre-headless state=latest # the next steps we can skip here because we run the db-role first # thanks to the java app wich has the db uri hard coded # #- name: install mariadb-client # apt: name=mariadb-client state=latest # #- name: install PyMySQL # apt: name=python3-pymysql state=latest # #- name: copy database schema file # copy: # src: files/schema.sql # dest: /tmp # #- name: copy database data file # copy: # src: files/data.sql # dest: /tmp - name: add user for jokesdb ansible.builtin.user: name: jokesdb comment: user to run application jokesdb create_home: True home: /var/jokesdb - name: that destination path exists file: path: /var/jokesdb/bin state: directory - name: copy architecture-refcard-03-0.0.1-SNAPSHOT.jar copy: src: files/architecture-refcard-03-0.0.1-SNAPSHOT.jar dest: /var/jokesdb/bin # we run this only because we want to show that it works - name: import db schema community.mysql.mysql_db: state: import name: jokedb login_host: "{{ db_address }}" login_user: "{{ db_username }}" login_password: "{{ db_password }}" target: /tmp/schema.sql - name: import db data community.mysql.mysql_db: state: import name: "{{ db_name }}" login_host: "{{ db_address }}" login_user: "{{ db_username }}" login_password: "{{ db_password }}" target: /tmp/data.sql - name: create default file for application ansible.builtin.template: src: templates/jokesdb.j2 dest: /etc/default/jokesdb - name: create service file to start the application ansible.builtin.template: src: templates/jokesdb_service.j2 dest: /etc/systemd/system/jokesdb.service - name: start jokesdb systemd: state=started name=jokesdb daemon_reload=yes