blob: 4e4235ceb358d44aa3466bde784d10848dde3ec1 [file] [log] [blame]
Mohammed Naser12207172024-02-05 18:49:35 -05001# Copyright (c) 2024 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- name: Wait for user to read warning
16 hosts: localhost
17 tasks:
18 - name: Wait for user to read warning
19 ignore_errors: true # noqa: ignore-errors
20 ansible.builtin.fail:
21 msg: >-
22 ⚠️
23 This code will make substantial changes to your machine, it is strongly
24 recommended that you run this on a server or virtual machine that you
25 dedicate to this purpose.
26 ⚠️
27
28 - name: Wait for user to read warning
29 ansible.builtin.wait_for:
30 timeout: 15
31
32- name: Generate workspace
33 ansible.builtin.import_playbook: vexxhost.atmosphere.generate_workspace
34 vars:
35 workspace_path: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}"
36 domain_name: "{{ ansible_default_ipv4['address'].replace('.', '-') }}.{{ lookup('env', 'ATMOSPHERE_DNS_SUFFIX_NAME') | default('nip.io', True) }}"
37
38- name: Setup networking
39 hosts: all
40 become: true
41 vars:
42 management_bridge: "br-mgmt"
43 tasks:
44 - name: Create bridge for management network
45 ignore_errors: true # noqa: ignore-errors
46 changed_when: false
47 ansible.builtin.command:
48 cmd: "ip link add name {{ management_bridge }} type bridge"
49
50 - name: Create fake interface for management bridge
51 ignore_errors: true # noqa: ignore-errors
52 changed_when: false
53 ansible.builtin.command:
54 cmd: "ip link add dummy0 type dummy"
55
56 # NOTE(mnaser): The bridge will not go up until it has an interface
57 # so we need to assign the dummy interface to the bridge
58 - name: Assign dummy interface to management bridge
59 ignore_errors: true # noqa: ignore-errors
60 changed_when: false
61 ansible.builtin.command:
62 cmd: "ip link set dummy0 master {{ management_bridge }}"
63
64 - name: Assign IP address for management bridge
65 ignore_errors: true # noqa: ignore-errors
66 changed_when: false
67 ansible.builtin.command:
68 cmd: "ip addr add 10.96.240.200/24 dev {{ management_bridge }}"
69
70 - name: Bring up interfaces
71 ignore_errors: true # noqa: ignore-errors
72 changed_when: false
73 ansible.builtin.command:
74 cmd: "ip link set {{ item }} up"
75 loop:
76 - br-mgmt
77 - dummy0
78
79- name: Setup host for deployment
80 hosts: all
81 become: true
82 tasks:
83 - name: Purge "snapd" package
84 become: true
85 ansible.builtin.apt:
86 name: snapd
87 state: absent
88 purge: true
89
90 # TODO(mnaser): Get rid of this once default workspace uses this.
91 - name: Overwrite existing osds.yml file
92 ansible.builtin.copy:
93 dest: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}/group_vars/cephs/osds.yml"
94 mode: '0644'
95 content: |
96 ceph_osd_devices:
97 - "/dev/ceph-{{ inventory_hostname_short }}-osd0/data"
98 - "/dev/ceph-{{ inventory_hostname_short }}-osd1/data"
99 - "/dev/ceph-{{ inventory_hostname_short }}-osd2/data"