-
-
Notifications
You must be signed in to change notification settings - Fork 6
Convert provisioning shell scripts to reusable Ansible playbooks (#96) #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
BytePaul
wants to merge
12
commits into
precice:develop
Choose a base branch
from
BytePaul:feature/ansible-provisioning
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
47ba29c
Add Ansible playbooks for reusable provisioning (#96)
BytePaul 0c130d0
Re-add Ansible playbooks as regular files
BytePaul 1d3de51
ADd GUI Installation
BytePaul bf23b84
CI added
BytePaul 822938e
Update README.md
BytePaul 79d686e
Update README.md
BytePaul d18bd9d
Merge branch 'feature/ansible-provisioning' of github.com:BytePaul/vm…
BytePaul d178fd7
Trigger CI
BytePaul 3effe14
Trigger CI
BytePaul ebe1827
Modified CI
BytePaul 59ab775
Basics: Add/edit comments, remove an unnecessary task
MakisH 5959ca6
Cleaup README.md
MakisH File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| 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 | ||
| " | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would be the way to run everything? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need this, right?
Suggested change
|
||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.