blob: f3337d9f23165a753201d08c7e4d4c4c0a300157 [file] [log] [blame]
Mohammed Naser3f961782023-04-20 10:48:21 -04001# Copyright (c) 2023 VEXXHOST, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15- import_playbook: vexxhost.atmosphere.generate_workspace
16 vars:
17 workspace_path: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}"
18 domain_name: "{{ '{{' }} ansible_default_ipv4['address'].replace('.', '-') {{ '}}' }}.{{ lookup('env', 'ATMOSPHERE_DNS_SUFFIX_NAME') | default('nip.io', True) }}"
19
20- name: Prepare
21 hosts: all
22 become: true
23 pre_tasks:
24 - name: Wait for systemd to complete initialization
25 ansible.builtin.command: systemctl is-system-running
26 register: systemctl_status
27 until: >
28 'running' in systemctl_status.stdout or
29 'degraded' in systemctl_status.stdout
30 retries: 30
31 delay: 5
32 changed_when: false
33 failed_when: systemctl_status.rc > 1
34 tasks:
35 - name: Refresh cache & install "iptables"
36 ansible.builtin.package:
37 name: iptables
38 update_cache: true
39
40 # NOTE(mnaser): The base image installs Ansible using `pip` which breaks
41 # the system Python, we uninstall all Python packages.
42 - name: Fix Python installation
43 block:
44 - name: Get all Python packages
45 ansible.builtin.command: pip freeze
46 register: pip_freeze
47
48 - name: Uninstall all Python packages
49 ansible.builtin.pip:
50 name: "{{ pip_freeze.stdout_lines }}"
51 state: absent
52
53- ansible.builtin.import_playbook: vexxhost.ceph.create_fake_devices
54
55- hosts: controllers
56 become: true
57 tasks:
58 - name: Overwrite existing osds.yml file
59 delegate_to: localhost
60 ansible.builtin.copy:
61 dest: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}/group_vars/cephs/osds.yml"
62 content: |
63 ceph_osd_devices:
64 - "/dev/ceph-{{ inventory_hostname_short }}-osd0/data"
65 - "/dev/ceph-{{ inventory_hostname_short }}-osd1/data"
66 - "/dev/ceph-{{ inventory_hostname_short }}-osd2/data"
67
68 - name: Set masquerade rule
69 become: yes
70 ansible.builtin.iptables:
71 table: nat
72 chain: POSTROUTING
73 source: 10.96.250.0/24
74 out_interface: "{{ ansible_default_ipv4.interface }}"
75 jump: MASQUERADE