Use Ansible to provision
This commit is contained in:
parent
90f761a7d0
commit
8dcb0ada57
5 changed files with 75 additions and 25 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
.vagrant
|
||||
root/.ssh/
|
||||
ssh_config
|
||||
|
|
25
Vagrantfile
vendored
25
Vagrantfile
vendored
|
@ -16,9 +16,6 @@ Vagrant.configure("2") do |config|
|
|||
shell.inline = <<-SHELL
|
||||
chown -R root:root /root/.ssh
|
||||
apt-get update
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get dist-upgrade -y
|
||||
apt-get install -y docker.io
|
||||
SHELL
|
||||
end
|
||||
|
||||
|
@ -31,28 +28,6 @@ Vagrant.configure("2") do |config|
|
|||
libvirt.memory = 1024
|
||||
libvirt.cpus = 1
|
||||
end
|
||||
guest.vm.provision "bootstrap", type: "shell" do |shell|
|
||||
shell.inline = <<-SHELL
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get install -y cephadm
|
||||
cephadm add-repo --release reef
|
||||
apt-get update
|
||||
apt-get dist-upgrade -y
|
||||
cephadm install ceph-common
|
||||
cephadm bootstrap --mon-ip 10.0.0.11
|
||||
SHELL
|
||||
end
|
||||
guest.vm.provision "add-hosts", type: "shell", after: "bootstrap" do |shell|
|
||||
shell.inline = <<-SHELL
|
||||
ceph orch host add ceph-mon-02 10.0.0.12 --labels _admin
|
||||
ceph orch host add ceph-mon-03 10.0.0.13 --labels _admin
|
||||
SHELL
|
||||
end
|
||||
guest.vm.provision "set-mon-net", type: "shell", after: "bootstrap" do |shell|
|
||||
shell.inline = <<-SHELL
|
||||
ceph config set mon public_network 10.0.0.0/24
|
||||
SHELL
|
||||
end
|
||||
end
|
||||
config.vm.define "ceph-mon-02" do |guest|
|
||||
guest.vm.box = "generic/ubuntu2204"
|
||||
|
|
7
ansible.cfg
Normal file
7
ansible.cfg
Normal file
|
@ -0,0 +1,7 @@
|
|||
[defaults]
|
||||
stdout_callback = yaml
|
||||
inventory = inventory/
|
||||
|
||||
[ssh_connection]
|
||||
pipelining = True
|
||||
ssh_args = -o ControlMaster=auto -o ControlPersist=120s -F ssh_config
|
16
inventory/hosts
Normal file
16
inventory/hosts
Normal file
|
@ -0,0 +1,16 @@
|
|||
ceph-mon-01 remote_user=vagrant
|
||||
ceph-mon-02 remote_user=vagrant
|
||||
ceph-mon-03 remote_user=vagrant
|
||||
ceph-osd-01 remote_user=vagrant
|
||||
ceph-osd-02 remote_user=vagrant
|
||||
ceph-osd-03 remote_user=vagrant
|
||||
|
||||
[mons]
|
||||
ceph-mon-01
|
||||
ceph-mon-02
|
||||
ceph-mon-03
|
||||
|
||||
[osds]
|
||||
ceph-osd-01
|
||||
ceph-osd-02
|
||||
ceph-osd-03
|
51
playbook.yml
Normal file
51
playbook.yml
Normal file
|
@ -0,0 +1,51 @@
|
|||
---
|
||||
|
||||
- name: Update and install docker
|
||||
hosts: all
|
||||
tasks:
|
||||
- name: Install docker
|
||||
become: true
|
||||
ansible.builtin.apt:
|
||||
name: docker.io
|
||||
|
||||
- name: Bootstrap ceph on mon-01
|
||||
hosts: ceph-mon-01
|
||||
tasks:
|
||||
- name: Install cephadm
|
||||
become: true
|
||||
ansible.builtin.apt:
|
||||
name: cephadm
|
||||
- name: Add reef ceph repo
|
||||
become: true
|
||||
ansible.builtin.command:
|
||||
cmd: cephadm add-repo --release reef
|
||||
creates: /etc/apt/sources.list.d/ceph.list
|
||||
- name: Install ceph-common
|
||||
become: true
|
||||
ansible.builtin.apt:
|
||||
name: ceph-common
|
||||
update_cache: true
|
||||
- name: Bootstrap cluster
|
||||
become: true
|
||||
ansible.builtin.command:
|
||||
cmd: cephadm bootstrap --mon-ip 10.0.0.11
|
||||
creates: /etc/ceph/ceph.conf
|
||||
|
||||
- name: Add other mons as ceph hosts
|
||||
hosts: ceph-mon-01
|
||||
tasks:
|
||||
- name: Add ceph hosts
|
||||
become: true
|
||||
ansible.builtin.command:
|
||||
cmd: "ceph orch host add {{ item.host }} {{ item.ip }} --labels _admin"
|
||||
loop:
|
||||
- host: ceph-mon-02
|
||||
ip: 10.0.0.12
|
||||
- host: ceph-mon-03
|
||||
ip: 10.0.0.13
|
||||
changed_when: false
|
||||
- name: Set mon network to autojoin other mons
|
||||
become: true
|
||||
ansible.builtin.command:
|
||||
cmd: ceph config set mon public_network 10.0.0.0/24
|
||||
changed_when: false
|
Loading…
Reference in a new issue