From 47ba29cd0ad65e9e95b55504fc47c086b6520b9b Mon Sep 17 00:00:00 2001 From: BytePaul Date: Wed, 30 Jul 2025 22:53:55 +0000 Subject: [PATCH 01/11] Add Ansible playbooks for reusable provisioning (#96) --- ansible | 1 + 1 file changed, 1 insertion(+) create mode 160000 ansible diff --git a/ansible b/ansible new file mode 160000 index 0000000..5fba692 --- /dev/null +++ b/ansible @@ -0,0 +1 @@ +Subproject commit 5fba692f244995c91f55b228ed62a0197e8b0a1c From 0c130d0688aba9bd4273dc6eee313629b56ba31e Mon Sep 17 00:00:00 2001 From: BytePaul Date: Thu, 31 Jul 2025 15:01:10 +0000 Subject: [PATCH 02/11] Re-add Ansible playbooks as regular files --- ansible | 1 - ansible/README.md | 68 +++++++ ansible/inventory.ini | 5 + ansible/playbooks/install-aste.yml | 70 +++++++ ansible/playbooks/install-basics.yml | 17 ++ ansible/playbooks/install-calculix.yml | 65 ++++++ ansible/playbooks/install-code_aster.yml | 151 ++++++++++++++ .../playbooks/install-config-visualizer.yml | 91 +++++++++ ansible/playbooks/install-dealii.yml | 52 +++++ ansible/playbooks/install-devel.yml | 19 ++ ansible/playbooks/install-dune.yml | 117 +++++++++++ ansible/playbooks/install-fenics.yml | 67 ++++++ ansible/playbooks/install-fmiprecice.yml | 17 ++ ansible/playbooks/install-julia-bindings.yml | 47 +++++ ansible/playbooks/install-micro-manager.yml | 17 ++ ansible/playbooks/install-openfoam.yml | 61 ++++++ ansible/playbooks/install-paraview.yml | 12 ++ ansible/playbooks/install-precice.yml | 191 ++++++++++++++++++ ansible/playbooks/install-su2.yml | 93 +++++++++ ansible/playbooks/install-vscode.yml | 22 ++ 20 files changed, 1182 insertions(+), 1 deletion(-) delete mode 160000 ansible create mode 100644 ansible/README.md create mode 100644 ansible/inventory.ini create mode 100644 ansible/playbooks/install-aste.yml create mode 100644 ansible/playbooks/install-basics.yml create mode 100644 ansible/playbooks/install-calculix.yml create mode 100644 ansible/playbooks/install-code_aster.yml create mode 100644 ansible/playbooks/install-config-visualizer.yml create mode 100644 ansible/playbooks/install-dealii.yml create mode 100644 ansible/playbooks/install-devel.yml create mode 100644 ansible/playbooks/install-dune.yml create mode 100644 ansible/playbooks/install-fenics.yml create mode 100644 ansible/playbooks/install-fmiprecice.yml create mode 100644 ansible/playbooks/install-julia-bindings.yml create mode 100644 ansible/playbooks/install-micro-manager.yml create mode 100644 ansible/playbooks/install-openfoam.yml create mode 100644 ansible/playbooks/install-paraview.yml create mode 100644 ansible/playbooks/install-precice.yml create mode 100644 ansible/playbooks/install-su2.yml create mode 100644 ansible/playbooks/install-vscode.yml diff --git a/ansible b/ansible deleted file mode 160000 index 5fba692..0000000 --- a/ansible +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5fba692f244995c91f55b228ed62a0197e8b0a1c diff --git a/ansible/README.md b/ansible/README.md new file mode 100644 index 0000000..e10e13d --- /dev/null +++ b/ansible/README.md @@ -0,0 +1,68 @@ +Ansible Playbooks for preCICE Development Environment Setup +This repository contains a set of Ansible playbooks that automate the provisioning of the preCICE development environment. These playbooks are converted from original `.sh` shell scripts, making the setup process modular, idempotent, and more maintainable. +## ๐Ÿ“ Directory Structure + +ansible/ +โ”œโ”€โ”€ inventory.ini # Target hosts configuration +โ”œโ”€โ”€ playbooks/ # Individual provisioning playbooks +โ”‚ โ”œโ”€โ”€ install-basics.yml +โ”‚ โ”œโ”€โ”€ install-aste.yml +โ”‚ โ”œโ”€โ”€ install-calculix.yml +โ”‚ โ”œโ”€โ”€ install-code_aster.yml +โ”‚ โ”œโ”€โ”€ install-config-visualizer.yml +โ”‚ โ”œโ”€โ”€ install-dealii.yml +โ”‚ โ”œโ”€โ”€ install-devel.yml +โ”‚ โ”œโ”€โ”€ install-dune.yml +โ”‚ โ”œโ”€โ”€ install-fenics.yml +โ”‚ โ”œโ”€โ”€ install-fmiprecice.yml +โ”‚ โ”œโ”€โ”€ install-julia-bindings.yml +โ”‚ โ”œโ”€โ”€ install-micro-manager.yml +โ”‚ โ”œโ”€โ”€ install-openfoam.yml +โ”‚ โ”œโ”€โ”€ install-paraview.yml +โ”‚ โ”œโ”€โ”€ install-precice.yml +โ”‚ โ”œโ”€โ”€ install-su2.yml +โ”‚ โ””โ”€โ”€ install-vscode.yml +โ””โ”€โ”€ README.md # This file + +## โœ… Purpose +These playbooks set up all necessary software components and development tools for contributing to or working with preCICE, a coupling library for partitioned multi-physics simulations. +The playbooks were translated from original shell scripts to: +- Ensure idempotency (safe to re-run) +- Improve clarity and maintainability +- Allow easier customization and reuse +- Support inventory-based execution (local or remote hosts) +## ๐Ÿ› ๏ธ Conversion: Shell Script โ†’ Ansible Playbook + +| Shell Script Action | Ansible Equivalent | +|--------------------------------|--------------------------------| +| apt-get update/install | apt module with update_cache | +| adduser, usermod | user and group modules | +| chmod +x / mkdir -p | file module with mode/path | +| curl or wget scripts | get_url or uri module | +| bash install.sh | script or command module | +| systemctl enable/start | systemd module | + +## ๐Ÿš€ Usage +### 1. Clone the repository +git clone https://github.com//ansible.git +cd ansible +### 2. Update inventory +[local] +localhost ansible_connection=local +### 3. Run a playbook +ansible-playbook -i inventory.ini playbooks/install-precice.yml +## ๐Ÿ” Testing & Validation +- All playbooks tested on Ubuntu 22.04 using Vagrant VM +- Playbooks support `--check` mode for dry-run testing +ansible-playbook -i inventory.ini playbooks/install-precice.yml --check --diff +- Playbooks can be extended with tags and variables +## ๐Ÿ“Œ Notes +- These playbooks do not use Ansible roles yet, but future restructuring may modularize common logic (e.g., user setup, package installation) +- Ensure Python and `sudo` are available on the target machines +## ๐Ÿ“ˆ Next Steps +- Add Molecule-based testing +- Introduce group_vars for better parameterization +- Modularize with Ansible roles (e.g., docker, precice, visualization) +## ๐Ÿค Contributing +Pull requests and suggestions are welcome! If you have a shell script youโ€™d like converted into an Ansible playbook, open an issue or contribute directly. + diff --git a/ansible/inventory.ini b/ansible/inventory.ini new file mode 100644 index 0000000..217b502 --- /dev/null +++ b/ansible/inventory.ini @@ -0,0 +1,5 @@ +[local] +localhost ansible_connection=local + +[remote] +# Example: server1 ansible_host=192.168.1.100 ansible_user=youruser diff --git a/ansible/playbooks/install-aste.yml b/ansible/playbooks/install-aste.yml new file mode 100644 index 0000000..cbbd749 --- /dev/null +++ b/ansible/playbooks/install-aste.yml @@ -0,0 +1,70 @@ +--- +- name: Install aste with dependencies + hosts: localhost + connection: local + become: true + vars: + user_home: "{{ lookup('env', 'HOME') }}" + aste_repo_url: "https://github.com/precice/aste.git" + aste_path: "{{ user_home }}/aste" + aste_venv_path: "{{ user_home }}/python-venvs/aste" + + tasks: + - name: Install system dependencies for aste + apt: + name: + - libvtk9-dev + - libvtk9-qt-dev + - libmetis-dev + - python3-venv + - python3-pip + state: present + update_cache: yes + + - name: Create Python virtual environment for aste + become: false + command: python3 -m venv {{ aste_venv_path }} + args: + creates: "{{ aste_venv_path }}/bin/activate" + + - name: Install Python packages in aste venv + become: false + shell: | + source {{ aste_venv_path }}/bin/activate + pip install --upgrade pip + pip install sympy scipy jinja2 + args: + executable: /bin/bash + + - name: Clone aste repository + become: false + git: + repo: "{{ aste_repo_url }}" + dest: "{{ aste_path }}" + version: master + depth: 1 + update: yes + + - name: Build aste project + become: false + shell: | + mkdir -p build && cd build + cmake .. + make -j $(nproc) + args: + chdir: "{{ aste_path }}" + executable: /bin/bash + + - name: Add aste build path to PATH in .bashrc + become: false + lineinfile: + path: "{{ user_home }}/.bashrc" + line: 'export PATH="${HOME}/aste/build:${PATH}"' + insertafter: EOF + + - name: Add aste build path to LD_LIBRARY_PATH in .bashrc + become: false + lineinfile: + path: "{{ user_home }}/.bashrc" + line: 'export LD_LIBRARY_PATH="${HOME}/aste/build:${LD_LIBRARY_PATH}"' + insertafter: EOF diff --git a/ansible/playbooks/install-basics.yml b/ansible/playbooks/install-basics.yml new file mode 100644 index 0000000..82257dc --- /dev/null +++ b/ansible/playbooks/install-basics.yml @@ -0,0 +1,17 @@ +# install-basics.yml +- name: Install basic packages + hosts: all + become: true + tasks: + - name: Update apt + apt: + update_cache: yes + + - name: Install essential packages + apt: + name: "{{ item }}" + state: present + loop: + - build-essential + - cmake + - git diff --git a/ansible/playbooks/install-calculix.yml b/ansible/playbooks/install-calculix.yml new file mode 100644 index 0000000..5e6c8fc --- /dev/null +++ b/ansible/playbooks/install-calculix.yml @@ -0,0 +1,65 @@ +--- +- name: Install CalculiX and the preCICE adapter + hosts: all + become: true + vars: + user_home: "{{ lookup('env', 'HOME') }}" + calculix_url: "http://www.dhondt.de/ccx_2.20.src.tar.bz2" + calculix_tarball: "ccx_2.20.src.tar.bz2" + calculix_dir: "ccx_2.20" + adapter_repo_url: "https://github.com/precice/calculix-adapter.git" + adapter_path: "{{ user_home }}/calculix-adapter" + + tasks: + - name: Install dependencies for CalculiX + apt: + name: + - libarpack2-dev + - libspooles-dev + - libyaml-cpp-dev + state: present + update_cache: yes + + - name: Download CalculiX source tarball + become: false + get_url: + url: "{{ calculix_url }}" + dest: "{{ user_home }}/{{ calculix_tarball }}" + mode: '0644' + + - name: Extract CalculiX source + become: false + unarchive: + src: "{{ user_home }}/{{ calculix_tarball }}" + dest: "{{ user_home }}" + remote_src: true + + - name: Remove CalculiX tarball + become: false + file: + path: "{{ user_home }}/{{ calculix_tarball }}" + state: absent + + - name: Clone CalculiX adapter repository + become: false + git: + repo: "{{ adapter_repo_url }}" + dest: "{{ adapter_path }}" + version: master + depth: 1 + update: yes + + - name: Build CalculiX adapter + become: false + shell: | + make -j $(nproc) ADDITIONAL_FFLAGS=-fallow-argument-mismatch + args: + chdir: "{{ adapter_path }}" + executable: /bin/bash + + - name: Add CalculiX adapter to PATH in .bashrc + become: false + lineinfile: + path: "{{ user_home }}/.bashrc" + line: 'export PATH="{{ user_home }}/calculix-adapter/bin:$PATH"' + insertafter: EOF diff --git a/ansible/playbooks/install-code_aster.yml b/ansible/playbooks/install-code_aster.yml new file mode 100644 index 0000000..bd415af --- /dev/null +++ b/ansible/playbooks/install-code_aster.yml @@ -0,0 +1,151 @@ +--- +- name: Install Code_Aster and its preCICE adapter + hosts: all + become: true + vars: + aster_url: "https://www.code-aster.org/FICHIERS/aster-full-src-14.6.0-1.noarch.tar.gz" + aster_tarball: "aster-full-src-14.6.0-1.noarch.tar.gz" + aster_extract_dir: "aster-full-src-14.6.0" + aster_install_path: "{{ ansible_env.HOME }}/code_aster" + adapter_repo_url: "https://github.com/precice/code_aster-adapter.git" + adapter_path: "{{ ansible_env.HOME }}/code_aster-adapter" + tutorial_path: "{{ ansible_env.HOME }}/tutorials/flow-over-heated-plate-steady-state" + + tasks: + - name: Install Code_Aster dependencies + apt: + name: + - bison + - cmake + - make + - flex + - g++ + - gcc + - gfortran + - grace + - liblapack-dev + - libblas-dev + - libboost-numpy-dev + - libboost-python-dev + - python3 + - python3-dev + - python3-numpy + - tk + - zlib1g-dev + state: present + update_cache: yes + + - name: Download Code_Aster tarball + become: false + get_url: + url: "{{ aster_url }}" + dest: "{{ ansible_env.HOME }}/{{ aster_tarball }}" + mode: '0644' + + - name: Extract Code_Aster source + become: false + unarchive: + src: "{{ ansible_env.HOME }}/{{ aster_tarball }}" + dest: "{{ ansible_env.HOME }}" + remote_src: yes + + - name: Install Code_Aster to user directory + become: false + shell: | + yes | python3 setup.py install --prefix="{{ aster_install_path }}" + args: + chdir: "{{ ansible_env.HOME }}/{{ aster_extract_dir }}" + executable: /bin/bash + + - name: Clean up extracted Code_Aster source + become: false + file: + path: "{{ ansible_env.HOME }}/{{ aster_extract_dir }}" + state: absent + + - name: Add Code_Aster to .bashrc + become: false + lineinfile: + path: "{{ ansible_env.HOME }}/.bashrc" + line: '. {{ aster_install_path }}/etc/codeaster/profile.sh' + insertafter: EOF + + - name: Clone Code_Aster adapter + become: false + git: + repo: "{{ adapter_repo_url }}" + dest: "{{ adapter_path }}" + version: master + depth: 1 + update: yes + + - name: Symlink adapter.py to Code_Aster Execution directory + become: false + file: + src: "{{ adapter_path }}/cht/adapter.py" + dest: "{{ aster_install_path }}/14.6/lib/aster/Execution/adapter.py" + state: link + + - name: Remove tests from Code_Aster to save space + become: false + file: + path: "{{ aster_install_path }}/14.6/share/aster/tests" + state: absent + + - name: Remove documentation from Code_Aster to save space + become: false + file: + path: "{{ aster_install_path }}/public/med-4.00/share/doc" + state: absent + + - name: Update exchange directory path in precice-config.xml + become: false + replace: + path: "{{ tutorial_path }}/precice-config.xml" + regexp: 'exchange-directory=".."' + replace: 'exchange-directory="{{ tutorial_path }}"' + + - name: Generate solid.export file for solid-codeaster + become: false + shell: | + if [ ! -f solid.export ]; then + cat < solid.export +P actions make_etude +P aster_root /code_aster +P consbtc oui +P debug nodebug +P display precicevm:0 +P follow_output yes +P mclient precicevm +P memjob 524288 +P memory_limit 512.0 +P mode interactif +P ncpus 1 +P nomjob linear-thermic +P origine salomemeca_asrun 1.10.0 +P protocol_copyfrom asrun.plugins.server.SCPServer +P protocol_copyto asrun.plugins.server.SCPServer +P protocol_exec asrun.plugins.server.SSHServer +P rep_trav /tmp/root-23129e00f0db-interactif_4800 +P serveur localhost +P soumbtc oui +P time_limit 600.0 +P tpsjob 11 +P uclient precicevm +P username precicevm +P version stable +A memjeveux 64.0 +A tpmax 600.0 +F comm ${HOME}/code_aster-adapter/cht/adapter.comm D 1 +F libr $(pwd)/config.comm D 90 +F libr $(pwd)/def.comm D 91 +F mmed $(pwd)/solid.mmed D 20 +R repe $(pwd)/REPE_OUT D 0 +R repe $(pwd)/REPE_OUT R 0 +F mess $(pwd)/solid.mess R 6 +F resu $(pwd)/solid.resu R 8 +EOF + fi + args: + chdir: "{{ tutorial_path }}/solid-codeaster" + executable: /bin/bash diff --git a/ansible/playbooks/install-config-visualizer.yml b/ansible/playbooks/install-config-visualizer.yml new file mode 100644 index 0000000..5fa1a53 --- /dev/null +++ b/ansible/playbooks/install-config-visualizer.yml @@ -0,0 +1,91 @@ +--- +- name: Install preCICE Config Visualizer CLI and GUI + hosts: all + become: true + vars: + user_home: "/home/vagrant" + visualizer_version: "1.1.3" + visualizer_gui_version: "0.1.0" + pipx_bin_path: "{{ user_home }}/.local/bin" + pipx_venv_gui_path: "{{ user_home }}/.local/share/pipx/venvs/precice-config-visualizer-gui/share" + + tasks: + - name: Install CLI dependencies (graphviz) + apt: + name: graphviz + state: present + update_cache: yes + + - name: Install system dependencies for GUI and PyGObject + apt: + name: + - build-essential + - pkg-config + - python3-dev + - libcairo2-dev + - libgirepository1.0-dev + - libglib2.0-dev + - libffi-dev # โœ… REQUIRED FOR PyGObject + - gir1.2-gtk-3.0 + - python3-gi + - python3-cairo + - meson + - ninja-build + state: present + update_cache: yes + + - name: Ensure pipx is installed + apt: + name: pipx + state: present + + - name: Install preCICE Config Visualizer CLI + become: false + shell: | + pipx install --force precice-config-visualizer=={{ visualizer_version }} + environment: + PATH: "{{ pipx_bin_path }}:{{ ansible_env.PATH }}" + args: + executable: /bin/bash + + - name: Install preCICE Config Visualizer GUI + become: false + shell: | + pipx install --force precice-config-visualizer-gui=={{ visualizer_gui_version }} + environment: + PATH: "{{ pipx_bin_path }}:{{ ansible_env.PATH }}" + args: + executable: /bin/bash + + - name: Add pipx bin path to PATH in .bashrc + become: false + lineinfile: + path: "{{ user_home }}/.bashrc" + line: 'export PATH="{{ pipx_bin_path }}:${PATH}"' + insertafter: EOF + + - name: Create user application and icon directories + become: false + file: + path: "{{ item }}" + state: directory + mode: '0755' + loop: + - "{{ user_home }}/.local/share/applications" + - "{{ user_home }}/.local/share/icons" + + - name: Copy GUI desktop file + become: false + copy: + src: "{{ pipx_venv_gui_path }}/applications/org.precice.config_visualizer.desktop" + dest: "{{ user_home }}/.local/share/applications/org.precice.config_visualizer.desktop" + remote_src: yes + mode: '0644' + + - name: Copy GUI icon file + become: false + copy: + src: "{{ pipx_venv_gui_path }}/icons/hicolor/scalable/apps/org.precice.config_visualizer.svg" + dest: "{{ user_home }}/.local/share/icons/org.precice.config_visualizer.svg" + remote_src: yes + mode: '0644' diff --git a/ansible/playbooks/install-dealii.yml b/ansible/playbooks/install-dealii.yml new file mode 100644 index 0000000..5b3cbb2 --- /dev/null +++ b/ansible/playbooks/install-dealii.yml @@ -0,0 +1,52 @@ +--- +- name: Install deal.II and the preCICE deal.II adapter + hosts: all + become: true + + vars: + adapter_repo_url: "https://github.com/precice/dealii-adapter.git" + + tasks: + - name: Update apt cache + apt: + update_cache: yes + + - name: Install libdeal.ii-dev package + apt: + name: libdeal.ii-dev + state: present + + - name: Set adapter path using actual user directory + set_fact: + adapter_path: "{{ lookup('env', 'HOME') }}/dealii-adapter" + become: false + + - name: Debug adapter path + become: false + debug: + msg: "Adapter will be cloned to: {{ adapter_path }}" + + - name: Clone deal.II adapter repo if not present + become: false + git: + repo: "{{ adapter_repo_url }}" + dest: "{{ adapter_path }}" + version: master + depth: 1 + update: yes + + - name: Build the deal.II adapter + become: false + shell: | + cmake . + make -j $(nproc) + args: + chdir: "{{ adapter_path }}" + executable: /bin/bash + + - name: Add deal.II adapter path to PATH in .bashrc + become: false + lineinfile: + path: "{{ lookup('env', 'HOME') }}/.bashrc" + line: 'export PATH="{{ adapter_path }}:${PATH}"' + insertafter: EOF diff --git a/ansible/playbooks/install-devel.yml b/ansible/playbooks/install-devel.yml new file mode 100644 index 0000000..6dfea65 --- /dev/null +++ b/ansible/playbooks/install-devel.yml @@ -0,0 +1,19 @@ +- name: Set up development environment + hosts: all + become: true + tasks: + - name: Install development tools and editors + apt: + name: + - build-essential + - git + - cmake + - cmake-curses-gui + - cargo + - nano + - vim + - gedit + - meld + - ipython3 + state: present + update_cache: yes diff --git a/ansible/playbooks/install-dune.yml b/ansible/playbooks/install-dune.yml new file mode 100644 index 0000000..af3db3a --- /dev/null +++ b/ansible/playbooks/install-dune.yml @@ -0,0 +1,117 @@ +--- +- name: Install DUNE, DuMux, and preCICE adapters + hosts: all + gather_facts: yes + vars: + home_dir: "{{ ansible_env.HOME }}" + dune_dir: "{{ home_dir }}/dune-dumux" + dune_modules: + - { name: dune-common, url: https://gitlab.dune-project.org/core/dune-common.git, branch: v2.9.1 } + - { name: dune-istl, url: https://gitlab.dune-project.org/core/dune-istl.git, branch: v2.9.1 } + - { name: dune-localfunctions, url: https://gitlab.dune-project.org/core/dune-localfunctions.git, branch: v2.9.1 } + - { name: dune-grid, url: https://gitlab.dune-project.org/core/dune-grid.git, branch: v2.9.1 } + - { name: dune-geometry, url: https://gitlab.dune-project.org/core/dune-geometry.git, branch: v2.9.1 } + - { name: dune-foamgrid, url: https://gitlab.dune-project.org/extensions/dune-foamgrid.git, branch: 2.9.1 } + - { name: dune-functions, url: https://gitlab.dune-project.org/staging/dune-functions.git, branch: v2.9.1 } + - { name: dune-typetree, url: https://gitlab.dune-project.org/staging/dune-typetree.git, branch: v2.9.1 } + - { name: dune-uggrid, url: https://gitlab.dune-project.org/staging/dune-uggrid.git, branch: v2.9.1 } + elastodynamics_repo: "https://github.com/maxfirmbach/dune-elastodynamics.git" + dune_adapter_repo: "https://github.com/precice/dune-adapter.git" + dumux_repo: "https://git.iws.uni-stuttgart.de/dumux-repositories/dumux.git" + dumux_adapter_repo: "https://github.com/precice/dumux-adapter.git" + + tasks: + - name: Install git if not present + become: true + apt: + name: git + state: present + update_cache: yes + + - name: Ensure dune-dumux directory exists + file: + path: "{{ dune_dir }}" + state: directory + + - name: Clone core DUNE modules + git: + repo: "{{ item.url }}" + dest: "{{ dune_dir }}/{{ item.name }}" + version: "{{ item.branch }}" + depth: 1 + update: yes + loop: "{{ dune_modules }}" + + - name: Clone dune-elastodynamics + git: + repo: "{{ elastodynamics_repo }}" + dest: "{{ dune_dir }}/dune-elastodynamics" + version: master + depth: 1 + update: yes + + - name: Pull latest dune-elastodynamics + shell: git pull + args: + chdir: "{{ dune_dir }}/dune-elastodynamics" + + - name: Clone dune-adapter + git: + repo: "{{ dune_adapter_repo }}" + dest: "{{ dune_dir }}/dune-adapter" + version: main + depth: 1 + update: yes + + - name: Pull latest dune-adapter + shell: git pull + args: + chdir: "{{ dune_dir }}/dune-adapter/dune-precice" + + - name: Build all DUNE modules with dunecontrol + shell: ./dune-common/bin/dunecontrol all + args: + chdir: "{{ dune_dir }}" + + - name: Clone DuMux repository + git: + repo: "{{ dumux_repo }}" + dest: "{{ dune_dir }}/dumux" + version: releases/3.8 + depth: 1 + update: yes + + - name: Build DuMux with dunecontrol + shell: | + CMAKE_FLAGS="$CMAKE_FLAGS -DCMAKE_DISABLE_FIND_PACKAGE_Kokkos=TRUE" ./dune-common/bin/dunecontrol --only=dumux all + args: + chdir: "{{ dune_dir }}" + executable: /bin/bash + + - name: Clone DuMux adapter + git: + repo: "{{ dumux_adapter_repo }}" + dest: "{{ dune_dir }}/dumux-adapter" + version: v2.0.0 + depth: 1 + update: yes + + - name: Build DuMux adapter with dunecontrol + shell: | + CMAKE_FLAGS="$CMAKE_FLAGS -DCMAKE_DISABLE_FIND_PACKAGE_Kokkos=TRUE" ./dune-common/bin/dunecontrol --only=dumux-precice all + args: + chdir: "{{ dune_dir }}" + executable: /bin/bash + + - name: Add DUNE_CONTROL_PATH to .bashrc + lineinfile: + path: "{{ home_dir }}/.bashrc" + line: 'export DUNE_CONTROL_PATH="{{ dune_dir }}"' + insertafter: EOF + + - name: Copy DUNE example to tutorials + copy: + src: "{{ dune_dir }}/dune-adapter/dune-precice-howto/build-cmake/examples/dune-perpendicular-flap" + dest: "{{ home_dir }}/tutorials/perpendicular-flap/solid-dune" + remote_src: yes + mode: '0755' diff --git a/ansible/playbooks/install-fenics.yml b/ansible/playbooks/install-fenics.yml new file mode 100644 index 0000000..6af49d9 --- /dev/null +++ b/ansible/playbooks/install-fenics.yml @@ -0,0 +1,67 @@ +--- +- name: Install FEniCS and the FEniCS-preCICE adapter + hosts: all + become: true + + vars: + distro_user: "{{ ansible_user_id }}" + + tasks: + - name: Get actual user home directory (not root) + become: false + set_fact: + distro_user_home: "{{ lookup('env', 'HOME') }}" + + - name: Set fenics venv path + set_fact: + fenics_venv_path: "{{ distro_user_home }}/python-venvs/fenicsprecice" + + - name: Install software-properties-common for add-apt-repository + apt: + name: software-properties-common + state: present + update_cache: yes + + - name: Add FEniCS APT repository + apt_repository: + repo: ppa:fenics-packages/fenics + state: present + + - name: Update APT cache after adding FEniCS repo + apt: + update_cache: yes + + - name: Install FEniCS without recommended packages + apt: + name: fenics + state: present + install_recommends: no + + - name: Install Python venv module and pip + apt: + name: + - python3-venv + - python3-pip + state: present + + - name: Ensure directory for virtual environments exists + become: false + file: + path: "{{ distro_user_home }}/python-venvs" + state: directory + mode: '0755' + + - name: Create virtual environment for FEniCS-preCICE + become: false + command: python3 -m venv {{ fenics_venv_path }} + args: + creates: "{{ fenics_venv_path }}/bin/activate" + + - name: Install fenicsprecice in virtual environment + become: false + shell: | + source {{ fenics_venv_path }}/bin/activate + pip install --upgrade pip + pip install fenicsprecice + args: + executable: /bin/bash diff --git a/ansible/playbooks/install-fmiprecice.yml b/ansible/playbooks/install-fmiprecice.yml new file mode 100644 index 0000000..afd863e --- /dev/null +++ b/ansible/playbooks/install-fmiprecice.yml @@ -0,0 +1,17 @@ +--- +- name: Install FMI-preCICE runner via pipx + hosts: all + become: true + + tasks: + - name: Ensure pipx is installed + apt: + name: pipx + state: present + update_cache: yes + + - name: Install fmiprecice using pipx + become: false + shell: pipx install fmiprecice + args: + executable: /bin/bash diff --git a/ansible/playbooks/install-julia-bindings.yml b/ansible/playbooks/install-julia-bindings.yml new file mode 100644 index 0000000..68ca288 --- /dev/null +++ b/ansible/playbooks/install-julia-bindings.yml @@ -0,0 +1,47 @@ +--- +- name: Install Julia and PreCICE Julia bindings + hosts: all + become: true + + tasks: + - name: Install python3-venv and pip + apt: + name: + - python3-venv + - python3-pip + state: present + update_cache: yes + +- name: Configure Julia environment as normal user + hosts: all + become: false + vars: + julia_venv_base: "{{ ansible_env.HOME }}/python-venvs" + julia_venv_path: "{{ julia_venv_base }}/julia" + + tasks: + - name: Ensure directory for virtual environments exists + file: + path: "{{ julia_venv_base }}" + state: directory + mode: '0755' + + - name: Create virtual environment for Julia + command: python3 -m venv {{ julia_venv_path }} + args: + creates: "{{ julia_venv_path }}/bin/activate" + + - name: Install jill and Julia via jill + shell: | + source {{ julia_venv_path }}/bin/activate + pip install --upgrade pip + pip install jill + jill install --confirm + args: + executable: /bin/bash + + - name: Install PreCICE Julia bindings + shell: | + ~/.local/bin/julia -e 'using Pkg; Pkg.add("PreCICE")' + args: + executable: /bin/bash diff --git a/ansible/playbooks/install-micro-manager.yml b/ansible/playbooks/install-micro-manager.yml new file mode 100644 index 0000000..cb27032 --- /dev/null +++ b/ansible/playbooks/install-micro-manager.yml @@ -0,0 +1,17 @@ +--- +- name: Install micro-manager-preCICE via pipx + hosts: all + become: true + + tasks: + - name: Ensure pipx is installed + apt: + name: pipx + state: present + update_cache: yes + + - name: Install micro-manager-precice using pipx + become: false + shell: pipx install micro-manager-precice + args: + executable: /bin/bash diff --git a/ansible/playbooks/install-openfoam.yml b/ansible/playbooks/install-openfoam.yml new file mode 100644 index 0000000..7445598 --- /dev/null +++ b/ansible/playbooks/install-openfoam.yml @@ -0,0 +1,61 @@ +--- +- name: Install OpenFOAM system-wide + hosts: all + become: true + + tasks: + - name: Add OpenFOAM signing key and repository + shell: wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | bash + args: + executable: /bin/bash + + - name: Install OpenFOAM v2312 + apt: + name: openfoam2312-dev + state: present + +- name: Setup OpenFOAM-preCICE for local user + hosts: all + become: false + vars: + openfoam_version: openfoam2312 + + tasks: + - name: Set actual user home + ansible.builtin.set_fact: + actual_home: "{{ ansible_env.HOME }}" + + - name: Enable OpenFOAM by default in .bashrc + lineinfile: + path: "{{ actual_home }}/.bashrc" + line: ". /usr/lib/openfoam/{{ openfoam_version }}/etc/bashrc" + create: yes + + - name: Clone OpenFOAM-preCICE adapter repository + git: + repo: https://github.com/precice/openfoam-adapter.git + dest: "{{ actual_home }}/openfoam-adapter" + version: master + depth: 1 + update: yes + + - name: Build OpenFOAM-preCICE adapter + shell: | + source /usr/lib/openfoam/{{ openfoam_version }}/etc/bashrc + ./Allclean + ./Allwmake + args: + chdir: "{{ actual_home }}/openfoam-adapter" + executable: /bin/bash + environment: + FOAM_INST_DIR: /usr/lib/openfoam + + - name: Build OpenFOAM solver in tutorial + shell: | + source /usr/lib/openfoam/{{ openfoam_version }}/etc/bashrc + wmake + args: + chdir: "{{ actual_home }}/tutorials/partitioned-heat-conduction/solver-openfoam" + executable: /bin/bash + environment: + FOAM_INST_DIR: /usr/lib/openfoam diff --git a/ansible/playbooks/install-paraview.yml b/ansible/playbooks/install-paraview.yml new file mode 100644 index 0000000..bb22313 --- /dev/null +++ b/ansible/playbooks/install-paraview.yml @@ -0,0 +1,12 @@ +--- +- name: Install ParaView without recommends + hosts: all + become: true + + tasks: + - name: Install ParaView without recommended packages + apt: + name: paraview + state: present + install_recommends: no + diff --git a/ansible/playbooks/install-precice.yml b/ansible/playbooks/install-precice.yml new file mode 100644 index 0000000..8e77955 --- /dev/null +++ b/ansible/playbooks/install-precice.yml @@ -0,0 +1,191 @@ +--- +- name: Install preCICE and related tutorials + hosts: all + become: true + vars: + user_home: "/home/vagrant" + precice_repo: "https://github.com/precice/precice.git" + tutorials_repo: "https://github.com/precice/tutorials.git" + fortran_module_repo: "https://github.com/precice/fortran-module.git" + python_bindings_repo: "https://github.com/precice/python-bindings.git" + precice_path: "{{ user_home }}/precice" + venv_path: "{{ user_home }}/python-venvs/pyprecice" + + tasks: + - name: Install preCICE build dependencies + apt: + name: + - cmake + - libeigen3-dev + - libxml2-dev + - libboost-all-dev + - petsc-dev + - python3-dev + - python3-numpy + state: present + update_cache: yes + + - name: Clone preCICE repo if not present + git: + repo: "{{ precice_repo }}" + dest: "{{ precice_path }}" + version: main + depth: 1 + update: yes + become: false + + - name: Build and package preCICE + become: false + shell: | + mkdir -p build && cd build + cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DPRECICE_RELEASE_WITH_DEBUG_LOG=ON -DBUILD_TESTING=OFF -Wno-dev .. + make -j $(nproc) + rm -fv ./*.deb && make package + sudo apt-get install -y ./libprecice*_*.deb + rm -rfv ./*.deb ./*.tar.gz _CPack_Packages + args: + chdir: "{{ precice_path }}" + executable: /bin/bash + + - name: Copy examples from /usr/share + copy: + remote_src: true + src: /usr/share/precice/examples/ + dest: "{{ precice_path }}-examples" + owner: vagrant + group: vagrant + mode: preserve + + - name: Build solverdummies (C, C++, Fortran) + shell: | + cd solverdummies + for d in c cpp fortran; do + cd $d && cmake . && make && cd .. + done + args: + chdir: "{{ precice_path }}-examples" + executable: /bin/bash + become: false + + - name: Clone and build fortran-module + git: + repo: "{{ fortran_module_repo }}" + dest: "{{ precice_path }}-examples/solverdummies/fortran-module" + depth: 1 + update: yes + become: false + + - name: Build fortran-module examples + shell: | + make + cd examples/solverdummy && make + args: + chdir: "{{ precice_path }}-examples/solverdummies/fortran-module" + executable: /bin/bash + become: false + + - name: Clone tutorials if not present + git: + repo: "{{ tutorials_repo }}" + dest: "{{ user_home }}/tutorials" + depth: 1 + update: yes + become: false + + - name: Ensure Desktop directory exists + file: + path: "{{ user_home }}/Desktop" + state: directory + mode: '0755' + become: false + + - name: Remove existing Desktop/tutorials if any + file: + path: "{{ user_home }}/Desktop/tutorials" + state: absent + become: false + + - name: Link tutorials to Desktop + file: + src: "{{ user_home }}/tutorials" + dest: "{{ user_home }}/Desktop/tutorials" + state: link + become: false + + - name: Build quickstart tutorial + shell: | + cmake . && make + args: + chdir: "{{ user_home }}/tutorials/quickstart/solid-cpp" + executable: /bin/bash + become: false + + - name: Vendor Rust dependencies for elastic-tube-1d + shell: | + mkdir -p .cargo && cargo vendor > .cargo/config.toml + args: + chdir: "{{ item }}" + executable: /bin/bash + loop: + - "{{ user_home }}/tutorials/elastic-tube-1d/solid-rust" + - "{{ user_home }}/tutorials/elastic-tube-1d/fluid-rust" + become: false + + - name: Run mesh download script for heat exchanger + shell: ./download-meshes.sh + args: + chdir: "{{ user_home }}/tutorials/heat-exchanger" + executable: /bin/bash + become: false + + - name: Install gnuplot + apt: + name: gnuplot + state: present + + - name: Install pip and venv + apt: + name: + - python3-pip + - python3-venv + state: present + + - name: Create Python venv for pyprecice + become: false + command: python3 -m venv {{ venv_path }} + args: + creates: "{{ venv_path }}/bin/activate" + + - name: Install pyprecice in venv + become: false + shell: | + source {{ venv_path }}/bin/activate + pip install --upgrade pip + pip install pyprecice + args: + executable: /bin/bash + + - name: Clone Python bindings repo and copy solverdummy + git: + repo: "{{ python_bindings_repo }}" + dest: "{{ user_home }}/python-bindings" + depth: 1 + update: yes + become: false + + - name: Copy python solverdummy example + copy: + src: "{{ user_home }}/python-bindings/examples/solverdummy" + dest: "{{ precice_path }}-examples/solverdummies/python" + remote_src: yes + owner: vagrant + group: vagrant + become: false + + - name: Remove python-bindings folder + file: + path: "{{ user_home }}/python-bindings" + state: absent + become: false diff --git a/ansible/playbooks/install-su2.yml b/ansible/playbooks/install-su2.yml new file mode 100644 index 0000000..047f4a2 --- /dev/null +++ b/ansible/playbooks/install-su2.yml @@ -0,0 +1,93 @@ +- name: Install SU2 and SU2-preCICE adapter + hosts: all + become: true + + vars: + su2_version: "7.5.1" + su2_tar: "v{{ su2_version }}.tar.gz" + su2_dir: "SU2-{{ su2_version }}" + su2_adapter_repo: "https://github.com/precice/su2-adapter.git" + + tasks: + - name: Create Python venv for SU2 adapter + ansible.builtin.shell: python3 -m venv ~/python-venvs/su2precice + args: + executable: /bin/bash + + - name: Activate venv and install pip dependencies + shell: | + source ~/python-venvs/su2precice/bin/activate + python -m pip install --upgrade pip + python -m pip install mpi4py setuptools + args: + executable: /bin/bash + + - name: Install swig + apt: + name: swig + state: present + + - name: Download SU2 {{ su2_version }} + get_url: + url: "https://github.com/su2code/SU2/archive/refs/tags/{{ su2_tar }}" + dest: "~/{{ su2_tar }}" + + - name: Extract SU2 + unarchive: + src: "~/{{ su2_tar }}" + dest: ~/ + remote_src: yes + + - name: Remove SU2 tarball + file: + path: "~/{{ su2_tar }}" + state: absent + + - name: Create ~/.su2-bashrc with SU2 environment variables + copy: + dest: ~/.su2-bashrc + content: | + export SU2_HOME="${HOME}/{{ su2_dir }}" + export SU2_RUN="${SU2_HOME}/SU2_CFD" + export PATH="${SU2_RUN}/bin/:${HOME}/su2-adapter/run/:${PATH}" + export PYTHONPATH="${SU2_RUN}/bin/:${PYTHONPATH}" + + - name: Source .su2-bashrc from .bashrc + lineinfile: + path: ~/.bashrc + line: ". ${HOME}/.su2-bashrc" + create: yes + + - name: Clone SU2 adapter + git: + repo: "{{ su2_adapter_repo }}" + dest: ~/su2-adapter + version: master + depth: 1 + + - name: Install SU2 adapter + shell: | + source ~/.su2-bashrc + ./su2AdapterInstall + args: + chdir: ~/su2-adapter + executable: /bin/bash + + - name: Fix missing header for Ubuntu 24.04 compatibility + lineinfile: + path: "~/{{ su2_dir }}/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp" + line: "#include " + insertafter: BOF + + - name: Configure and build SU2 with Python wrapper + shell: | + source ~/.su2-bashrc + ./meson.py build -Denable-pywrapper=true --prefix="${SU2_RUN}" && ./ninja -C build install + args: + chdir: "~/{{ su2_dir }}" + executable: /bin/bash + + - name: Remove libSU2Core.a to save space + file: + path: "~/{{ su2_dir }}/SU2_CFD/obj/libSU2Core.a" + state: absent diff --git a/ansible/playbooks/install-vscode.yml b/ansible/playbooks/install-vscode.yml new file mode 100644 index 0000000..38bb7c3 --- /dev/null +++ b/ansible/playbooks/install-vscode.yml @@ -0,0 +1,22 @@ +- name: Install Visual Studio Code and C++ extensions + hosts: all + become: true + + tasks: + - name: Install VS Code via snap + snap: + name: code + classic: true + state: present + + - name: Install C++ extension in VS Code + become: false + shell: code --install-extension ms-vscode.cpptools + args: + executable: /bin/bash + + - name: Install GNU Global extension in VS Code + become: false + shell: code --install-extension austin.code-gnu-global + args: + executable: /bin/bash From 1d3de514e39f8e3fff6f607fc1122b012e035858 Mon Sep 17 00:00:00 2001 From: BytePaul Date: Fri, 1 Aug 2025 11:27:46 +0000 Subject: [PATCH 03/11] ADd GUI Installation --- ansible/playbooks/install-basics.yml | 98 +++++++++++++++++++++++++--- 1 file changed, 89 insertions(+), 9 deletions(-) diff --git a/ansible/playbooks/install-basics.yml b/ansible/playbooks/install-basics.yml index 82257dc..1d24ad5 100644 --- a/ansible/playbooks/install-basics.yml +++ b/ansible/playbooks/install-basics.yml @@ -1,17 +1,97 @@ -# install-basics.yml -- name: Install basic packages +--- +- name: Install GUI, development tools, and setup VM environment hosts: all become: true + + vars: + keyboard_layout: us + hostname: precicevm + desktop_shortcut: /usr/share/applications/xfce-keyboard-settings.desktop + + pre_tasks: + - name: Remove bad APT retry config if present + file: + path: /etc/apt/apt.conf.d/80-retries + state: absent + + - name: Set correct APT retry config + copy: + dest: /etc/apt/apt.conf.d/80-retries + content: | + Acquire::Retries "4"; + force: yes + tasks: - - name: Update apt + - name: Add multiverse repository + apt_repository: + repo: "deb http://archive.ubuntu.com/ubuntu {{ ansible_distribution_release }} multiverse" + state: present + filename: multiverse + + - name: Update APT cache apt: update_cache: yes - - name: Install essential packages + - name: Upgrade packages + apt: + upgrade: dist + force_apt_get: yes + + - name: Install Xfce desktop environment + apt: + name: xubuntu-core + state: present + + - name: Install GUI and terminal apps apt: - name: "{{ item }}" + name: + - thunar + - xfce4-terminal + - terminator + - bash-completion + - tree + - atril + - firefox + - firefox-locale-en + - baobab + - catfish state: present - loop: - - build-essential - - cmake - - git + + - name: Install Python development tools + apt: + name: + - python3-dev + - pipx + - python-is-python3 + - python3-venv + state: present + + - name: Install VirtualBox Guest Additions + apt: + name: + - virtualbox-guest-utils + - virtualbox-guest-x11 + state: present + + - name: Create Desktop directory if not present + file: + path: "{{ ansible_env.HOME }}/Desktop" + state: directory + mode: '0755' + + - name: Set US keyboard layout + lineinfile: + path: /etc/default/keyboard + regexp: '^XKBLAYOUT=' + line: 'XKBLAYOUT="{{ keyboard_layout }}"' + + - name: Copy keyboard settings shortcut to Desktop + copy: + src: "{{ desktop_shortcut }}" + dest: "{{ ansible_env.HOME }}/Desktop/" + remote_src: yes + mode: '0755' + + - name: Set hostname + hostname: + name: "{{ hostname }}" From bf23b84a9f947f0ad90eec737a299af5ea3540ff Mon Sep 17 00:00:00 2001 From: BytePaul Date: Thu, 7 Aug 2025 21:39:13 +0000 Subject: [PATCH 04/11] CI added --- .github/workflows/ci.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..4649e53 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +name: Ansible CI with Docker + +on: [push, pull_request] + +jobs: + test-ansible: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Build environment + run: sudo apt-get update && sudo apt-get install -y docker.io + + - name: Build test container + run: | + docker build -t ansible-test -f - . < Date: Thu, 7 Aug 2025 23:52:27 +0200 Subject: [PATCH 05/11] Update README.md --- ansible/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ansible/README.md b/ansible/README.md index e10e13d..b2e04c7 100644 --- a/ansible/README.md +++ b/ansible/README.md @@ -1,7 +1,7 @@ Ansible Playbooks for preCICE Development Environment Setup This repository contains a set of Ansible playbooks that automate the provisioning of the preCICE development environment. These playbooks are converted from original `.sh` shell scripts, making the setup process modular, idempotent, and more maintainable. ## ๐Ÿ“ Directory Structure - +ยดยดยด ansible/ โ”œโ”€โ”€ inventory.ini # Target hosts configuration โ”œโ”€โ”€ playbooks/ # Individual provisioning playbooks @@ -23,7 +23,7 @@ ansible/ โ”‚ โ”œโ”€โ”€ install-su2.yml โ”‚ โ””โ”€โ”€ install-vscode.yml โ””โ”€โ”€ README.md # This file - +ยดยดยด ## โœ… Purpose These playbooks set up all necessary software components and development tools for contributing to or working with preCICE, a coupling library for partitioned multi-physics simulations. The playbooks were translated from original shell scripts to: From 79d686e18e41e486322bd0bf8e33ec6a8700b24a Mon Sep 17 00:00:00 2001 From: BytePaul <153028234+BytePaul@users.noreply.github.com> Date: Thu, 7 Aug 2025 23:52:59 +0200 Subject: [PATCH 06/11] Update README.md --- ansible/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ansible/README.md b/ansible/README.md index b2e04c7..d9a3e57 100644 --- a/ansible/README.md +++ b/ansible/README.md @@ -1,7 +1,7 @@ Ansible Playbooks for preCICE Development Environment Setup This repository contains a set of Ansible playbooks that automate the provisioning of the preCICE development environment. These playbooks are converted from original `.sh` shell scripts, making the setup process modular, idempotent, and more maintainable. ## ๐Ÿ“ Directory Structure -ยดยดยด +``` ansible/ โ”œโ”€โ”€ inventory.ini # Target hosts configuration โ”œโ”€โ”€ playbooks/ # Individual provisioning playbooks @@ -23,7 +23,7 @@ ansible/ โ”‚ โ”œโ”€โ”€ install-su2.yml โ”‚ โ””โ”€โ”€ install-vscode.yml โ””โ”€โ”€ README.md # This file -ยดยดยด +``` ## โœ… Purpose These playbooks set up all necessary software components and development tools for contributing to or working with preCICE, a coupling library for partitioned multi-physics simulations. The playbooks were translated from original shell scripts to: From d178fd7c674389fdbafba9b14353aa68f1f8880e Mon Sep 17 00:00:00 2001 From: BytePaul Date: Thu, 7 Aug 2025 21:53:50 +0000 Subject: [PATCH 07/11] Trigger CI From 3effe14ed45171f1dc8d9ccc6c2919dbcd6b0503 Mon Sep 17 00:00:00 2001 From: BytePaul Date: Thu, 7 Aug 2025 21:57:42 +0000 Subject: [PATCH 08/11] Trigger CI From ebe182731a0ae0e87834a57a49e0dd14a262644d Mon Sep 17 00:00:00 2001 From: BytePaul Date: Thu, 7 Aug 2025 21:59:03 +0000 Subject: [PATCH 09/11] Modified CI --- .github/workflows/ci.yml | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4649e53..278f0ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,29 +10,14 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Set up Docker Build environment - run: sudo apt-get update && sudo apt-get install -y docker.io + - name: Lint Ansible Playbooks ๐Ÿงน + uses: docker://ansible/ansible-lint:latest + with: + args: 'ansible/playbooks/' - - name: Build test container + - name: Check Ansible Playbook Syntax โœ… run: | - docker build -t ansible-test -f - . < Date: Thu, 7 Aug 2025 19:10:49 +0200 Subject: [PATCH 10/11] Basics: Add/edit comments, remove an unnecessary task --- ansible/playbooks/install-basics.yml | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/ansible/playbooks/install-basics.yml b/ansible/playbooks/install-basics.yml index 1d24ad5..bf8e9c3 100644 --- a/ansible/playbooks/install-basics.yml +++ b/ansible/playbooks/install-basics.yml @@ -1,19 +1,14 @@ --- -- name: Install GUI, development tools, and setup VM environment +- name: Install a dekstop environment, basic tools, and VM guest additions hosts: all become: true vars: keyboard_layout: us hostname: precicevm - desktop_shortcut: /usr/share/applications/xfce-keyboard-settings.desktop pre_tasks: - - name: Remove bad APT retry config if present - file: - path: /etc/apt/apt.conf.d/80-retries - state: absent - + # Some repos are a bit fragile and need multiple download tries. - name: Set correct APT retry config copy: dest: /etc/apt/apt.conf.d/80-retries @@ -22,6 +17,7 @@ force: yes tasks: + # We (may) need the multiverse repository for the VBox Guest Additions - name: Add multiverse repository apt_repository: repo: "deb http://archive.ubuntu.com/ubuntu {{ ansible_distribution_release }} multiverse" @@ -34,7 +30,7 @@ - name: Upgrade packages apt: - upgrade: dist + upgrade: yes force_apt_get: yes - name: Install Xfce desktop environment @@ -57,7 +53,7 @@ - catfish state: present - - name: Install Python development tools + - name: Install Python apt: name: - python3-dev @@ -79,7 +75,7 @@ state: directory mode: '0755' - - name: Set US keyboard layout + - name: Set keyboard layout lineinfile: path: /etc/default/keyboard regexp: '^XKBLAYOUT=' @@ -87,7 +83,7 @@ - name: Copy keyboard settings shortcut to Desktop copy: - src: "{{ desktop_shortcut }}" + src: /usr/share/applications/xfce-keyboard-settings.desktop dest: "{{ ansible_env.HOME }}/Desktop/" remote_src: yes mode: '0755' From 5959ca606a54141d5db3905a1c5cfe211c2121cd Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Fri, 8 Aug 2025 13:44:55 +0200 Subject: [PATCH 11/11] Cleaup README.md --- ansible/README.md | 73 ++++++----------------------------------------- 1 file changed, 8 insertions(+), 65 deletions(-) diff --git a/ansible/README.md b/ansible/README.md index d9a3e57..a14f650 100644 --- a/ansible/README.md +++ b/ansible/README.md @@ -1,68 +1,11 @@ -Ansible Playbooks for preCICE Development Environment Setup -This repository contains a set of Ansible playbooks that automate the provisioning of the preCICE development environment. These playbooks are converted from original `.sh` shell scripts, making the setup process modular, idempotent, and more maintainable. -## ๐Ÿ“ Directory Structure -``` -ansible/ -โ”œโ”€โ”€ inventory.ini # Target hosts configuration -โ”œโ”€โ”€ playbooks/ # Individual provisioning playbooks -โ”‚ โ”œโ”€โ”€ install-basics.yml -โ”‚ โ”œโ”€โ”€ install-aste.yml -โ”‚ โ”œโ”€โ”€ install-calculix.yml -โ”‚ โ”œโ”€โ”€ install-code_aster.yml -โ”‚ โ”œโ”€โ”€ install-config-visualizer.yml -โ”‚ โ”œโ”€โ”€ install-dealii.yml -โ”‚ โ”œโ”€โ”€ install-devel.yml -โ”‚ โ”œโ”€โ”€ install-dune.yml -โ”‚ โ”œโ”€โ”€ install-fenics.yml -โ”‚ โ”œโ”€โ”€ install-fmiprecice.yml -โ”‚ โ”œโ”€โ”€ install-julia-bindings.yml -โ”‚ โ”œโ”€โ”€ install-micro-manager.yml -โ”‚ โ”œโ”€โ”€ install-openfoam.yml -โ”‚ โ”œโ”€โ”€ install-paraview.yml -โ”‚ โ”œโ”€โ”€ install-precice.yml -โ”‚ โ”œโ”€โ”€ install-su2.yml -โ”‚ โ””โ”€โ”€ install-vscode.yml -โ””โ”€โ”€ README.md # This file -``` -## โœ… Purpose -These playbooks set up all necessary software components and development tools for contributing to or working with preCICE, a coupling library for partitioned multi-physics simulations. -The playbooks were translated from original shell scripts to: -- Ensure idempotency (safe to re-run) -- Improve clarity and maintainability -- Allow easier customization and reuse -- Support inventory-based execution (local or remote hosts) -## ๐Ÿ› ๏ธ Conversion: Shell Script โ†’ Ansible Playbook +# Ansible playbooks for preCICE -| Shell Script Action | Ansible Equivalent | -|--------------------------------|--------------------------------| -| apt-get update/install | apt module with update_cache | -| adduser, usermod | user and group modules | -| chmod +x / mkdir -p | file module with mode/path | -| curl or wget scripts | get_url or uri module | -| bash install.sh | script or command module | -| systemctl enable/start | systemd module | +This repository contains a set of Ansible playbooks that automate the provisioning of a system with preCICE and several adapters and further tools installed. These playbooks are converted from the original shell scripts, making the setup process modular, idempotent, and more maintainable. -## ๐Ÿš€ Usage -### 1. Clone the repository -git clone https://github.com//ansible.git -cd ansible -### 2. Update inventory -[local] -localhost ansible_connection=local -### 3. Run a playbook -ansible-playbook -i inventory.ini playbooks/install-precice.yml -## ๐Ÿ” Testing & Validation -- All playbooks tested on Ubuntu 22.04 using Vagrant VM -- Playbooks support `--check` mode for dry-run testing -ansible-playbook -i inventory.ini playbooks/install-precice.yml --check --diff -- Playbooks can be extended with tags and variables -## ๐Ÿ“Œ Notes -- These playbooks do not use Ansible roles yet, but future restructuring may modularize common logic (e.g., user setup, package installation) -- Ensure Python and `sudo` are available on the target machines -## ๐Ÿ“ˆ Next Steps -- Add Molecule-based testing -- Introduce group_vars for better parameterization -- Modularize with Ansible roles (e.g., docker, precice, visualization) -## ๐Ÿค Contributing -Pull requests and suggestions are welcome! If you have a shell script youโ€™d like converted into an Ansible playbook, open an issue or contribute directly. +To run a specific playbook, get Ansible (e.g., `sudo apt install ansible`) and execute from this directory, for example: + +```shell +ansible-playbook -i inventory.ini playbooks/install-basics.yml +``` +To check (dry-run) the playbooks, use the `--check --diff` flags.