Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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: Lint Ansible Playbooks 🧹
uses: docker://ansible/ansible-lint:latest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This image does not seem to exist on the public Docker Hub registry: https://hub.docker.com/search?q=ansible-lint Where is that recommended? Is there a common alternative?

This is the reason that the CI is currently failing.

with:
args: 'ansible/playbooks/'

- name: Check Ansible Playbook Syntax ✅
run: |
docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace ansible/ansible:latest bash -c "
for playbook in ansible/playbooks/*.yml; do
echo 'Checking syntax of' \$playbook
ansible-playbook -i ansible/inventory.ini --syntax-check \$playbook
done
"
11 changes: 11 additions & 0 deletions ansible/README.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the way to run everything?
Should we define hosts that execute different playbooks?
Should we use import?

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Ansible playbooks for preCICE

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.

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.
5 changes: 5 additions & 0 deletions ansible/inventory.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[local]
localhost ansible_connection=local

[remote]
# Example: server1 ansible_host=192.168.1.100 ansible_user=youruser
Comment on lines +3 to +5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this, right?

Suggested change
[remote]
# Example: server1 ansible_host=192.168.1.100 ansible_user=youruser

70 changes: 70 additions & 0 deletions ansible/playbooks/install-aste.yml
Original file line number Diff line number Diff line change
@@ -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
93 changes: 93 additions & 0 deletions ansible/playbooks/install-basics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
- name: Install a dekstop environment, basic tools, and VM guest additions
hosts: all
become: true

vars:
keyboard_layout: us
hostname: precicevm

pre_tasks:
# 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
content: |
Acquire::Retries "4";
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"
state: present
filename: multiverse

- name: Update APT cache
apt:
update_cache: yes

- name: Upgrade packages
apt:
upgrade: yes
force_apt_get: yes

- name: Install Xfce desktop environment
apt:
name: xubuntu-core
state: present

- name: Install GUI and terminal apps
apt:
name:
- thunar
- xfce4-terminal
- terminator
- bash-completion
- tree
- atril
- firefox
- firefox-locale-en
- baobab
- catfish
state: present

- name: Install Python
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 keyboard layout
lineinfile:
path: /etc/default/keyboard
regexp: '^XKBLAYOUT='
line: 'XKBLAYOUT="{{ keyboard_layout }}"'

- name: Copy keyboard settings shortcut to Desktop
copy:
src: /usr/share/applications/xfce-keyboard-settings.desktop
dest: "{{ ansible_env.HOME }}/Desktop/"
remote_src: yes
mode: '0755'

- name: Set hostname
hostname:
name: "{{ hostname }}"
65 changes: 65 additions & 0 deletions ansible/playbooks/install-calculix.yml
Original file line number Diff line number Diff line change
@@ -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
Loading