Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 429a947cb9 | |||
| 12ee092bda |
@@ -1,9 +0,0 @@
|
|||||||
# Ignore Vagrant working directory
|
|
||||||
.vagrant/
|
|
||||||
|
|
||||||
# Optional: Ignore other common system files
|
|
||||||
*.log
|
|
||||||
*.swp
|
|
||||||
*.swo
|
|
||||||
.DS_Store
|
|
||||||
Thumbs.db
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
repos:
|
|
||||||
- repo: https://github.com/ashwin153/pre-commit-vagrant
|
|
||||||
rev: v1.1.0
|
|
||||||
hooks:
|
|
||||||
- id: vagrant-validate
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"dependencies":[["racc",["~> 1.4"]],["nokogiri",[">= 0"]],["vagrant-parallels",["= 2.4.7"]],["vagrant-vmware-desktop",["= 3.0.5"]]],"checksum":"bda880323205a2179a2f8e0ce812b0b90f732cad5437390c49347d071a7a7210","vagrant_version":"2.4.9"}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
1.5:0fac0b3a-1d44-4e82-ae4c-94e2bb58f24e
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
1756366117
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"name":"bento/ubuntu-22.04","version":"202508.03.0","provider":"parallels","directory":"boxes/bento-VAGRANTSLASH-ubuntu-22.04/202508.03.0/arm64/parallels"}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
501
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0fac0b3a-1d44-4e82-ae4c-94e2bb58f24e
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
7da79dce5dd248389646d5d2f10c0952
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||||
|
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAA
|
||||||
|
AAtzc2gtZWQyNTUxOQAAACBtbRVm/S3R79LI46zjLL1U5mcssW8OAuQ7sMeb
|
||||||
|
AMoDXwAAAJD1JDKN9SQyjQAAAAtzc2gtZWQyNTUxOQAAACBtbRVm/S3R79LI
|
||||||
|
46zjLL1U5mcssW8OAuQ7sMebAMoDXwAAAEBcCb8RRSin6mQgityah98d31J5
|
||||||
|
JA7MZwgV4/U3iLMxkW1tFWb9LdHv0sjjrOMsvVTmZyyxbw4C5Duwx5sAygNf
|
||||||
|
AAAAB3ZhZ3JhbnQBAgMEBQY=
|
||||||
|
-----END OPENSSH PRIVATE KEY-----
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"parallels":{"/vagrant":{"guestpath":"/vagrant","hostpath":"/Users/xchose/vagrant/para","disabled":false,"__vagrantfile":true}}}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
/Users/xchose/vagrant/para
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
1.5:d188f064-60c9-4d5c-b213-9d41f53d6a83
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
1756367186
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"name":"bento/ubuntu-22.04","version":"202508.03.0","provider":"parallels","directory":"boxes/bento-VAGRANTSLASH-ubuntu-22.04/202508.03.0/arm64/parallels"}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
501
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
d188f064-60c9-4d5c-b213-9d41f53d6a83
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
fbc215c9adf044818edb0abf1629dcef
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||||
|
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAA
|
||||||
|
AAtzc2gtZWQyNTUxOQAAACAtBN7H9y8n0wvvTQF1F/tf/55Q6DpBlJSA/+hm
|
||||||
|
rRCGTgAAAJDUeA7b1HgO2wAAAAtzc2gtZWQyNTUxOQAAACAtBN7H9y8n0wvv
|
||||||
|
TQF1F/tf/55Q6DpBlJSA/+hmrRCGTgAAAEBoKNrNIIkrzMfDHQ4zpdLIlP9w
|
||||||
|
iwuZoZUi5RaKKzKs8i0E3sf3LyfTC+9NAXUX+1//nlDoOkGUlID/6GatEIZO
|
||||||
|
AAAAB3ZhZ3JhbnQBAgMEBQY=
|
||||||
|
-----END OPENSSH PRIVATE KEY-----
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"parallels":{"/vagrant":{"guestpath":"/vagrant","hostpath":"/Users/xchose/vagrant/para","disabled":false,"__vagrantfile":true}}}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
/Users/xchose/vagrant/para
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# Copyright (c) HashiCorp, Inc.
|
||||||
|
# SPDX-License-Identifier: BUSL-1.1
|
||||||
|
|
||||||
|
# This file loads the proper rgloader/loader.rb file that comes packaged
|
||||||
|
# with Vagrant so that encoded files can properly run with Vagrant.
|
||||||
|
|
||||||
|
if ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"]
|
||||||
|
require File.expand_path(
|
||||||
|
"rgloader/loader", ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"])
|
||||||
|
else
|
||||||
|
raise "Encoded files can't be read outside of the Vagrant installer."
|
||||||
|
end
|
||||||
@@ -1,146 +0,0 @@
|
|||||||
# README.md
|
|
||||||
|
|
||||||
## Prerequisity
|
|
||||||
|
|
||||||
|
|
||||||
```
|
|
||||||
# Add the official HashiCorp tap for the latest Vagrant
|
|
||||||
brew tap hashicorp/tap
|
|
||||||
|
|
||||||
# Install Vagrant (latest version from HashiCorp tap)
|
|
||||||
brew install hashicorp/tap/hashicorp-vagrant
|
|
||||||
|
|
||||||
# Install the Vagrant VMware Utility (required for VMware provider integration)
|
|
||||||
brew install --cask vagrant-vmware-utility
|
|
||||||
|
|
||||||
# Install the Vagrant VMware Desktop plugin
|
|
||||||
vagrant plugin install vagrant-vmware-desktop
|
|
||||||
|
|
||||||
# (Optional) Install Vagrant from Homebrew cask if you prefer the cask version
|
|
||||||
# brew install --cask vagrant
|
|
||||||
|
|
||||||
# Check Vagrant version to verify installation
|
|
||||||
vagrant --version
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
List installed Vagrant plugins to verify plugin installation
|
|
||||||
vagrant plugin list
|
|
||||||
|
|
||||||
|
|
||||||
## Project Structure
|
|
||||||
|
|
||||||
```
|
|
||||||
/
|
|
||||||
├── Vagrantfile
|
|
||||||
├── vytvor_uzivatele.yml
|
|
||||||
└── hosts
|
|
||||||
```
|
|
||||||
|
|
||||||
- **Vagrantfile** – Defines the virtual machine.
|
|
||||||
- **vytvor_uzivatele.yml** – Ansible playbook for creating a user.
|
|
||||||
- **hosts** – Ansible inventory (used for manual runs).
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 1. Starting the VM with Vagrant
|
|
||||||
|
|
||||||
### First Boot or VM Creation
|
|
||||||
|
|
||||||
```
|
|
||||||
vagrant up
|
|
||||||
```
|
|
||||||
|
|
||||||
- This command downloads the required box (e.g., `bento/ubuntu-22.04`), creates, and starts the VM as defined in your Vagrantfile.
|
|
||||||
- If you have configured Ansible as a provisioner in the Vagrantfile, the playbook will run automatically after the VM is created.
|
|
||||||
|
|
||||||
### Re-running Provisioning
|
|
||||||
|
|
||||||
If you want to re-run provisioning (for example, after editing the playbook):
|
|
||||||
|
|
||||||
```
|
|
||||||
vagrant provision
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 2. Running Ansible Manually
|
|
||||||
|
|
||||||
If you prefer more control, you can run Ansible manually.
|
|
||||||
|
|
||||||
### Step 1: Start the VM
|
|
||||||
|
|
||||||
```
|
|
||||||
vagrant up
|
|
||||||
```
|
|
||||||
|
|
||||||
### Step 2: Get SSH Connection Details
|
|
||||||
|
|
||||||
```
|
|
||||||
vagrant ssh-config kube01
|
|
||||||
```
|
|
||||||
|
|
||||||
- Copy the relevant values into the `hosts` inventory file if they are not already set.
|
|
||||||
|
|
||||||
### Step 3: Run the Ansible Playbook
|
|
||||||
|
|
||||||
```
|
|
||||||
ansible-playbook -i hosts vytvor_uzivatele.yml
|
|
||||||
```
|
|
||||||
|
|
||||||
- This command will execute the tasks defined in the playbook on your VM.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 3. Example Files
|
|
||||||
|
|
||||||
### Vagrantfile (with Ansible provisioner)
|
|
||||||
|
|
||||||
```
|
|
||||||
Vagrant.configure("2") do |config|
|
|
||||||
config.vm.define "kube01" do |kube01|
|
|
||||||
kube01.vm.box = "bento/ubuntu-22.04"
|
|
||||||
kube01.vm.hostname = "kube01"
|
|
||||||
kube01.vm.provider "vmware_fusion" do |v|
|
|
||||||
v.gui = false
|
|
||||||
v.memory = 2048
|
|
||||||
v.cpus = 2
|
|
||||||
end
|
|
||||||
kube01.vm.provision "ansible" do |ansible|
|
|
||||||
ansible.playbook = "vytvor_uzivatele.yml"
|
|
||||||
ansible.verbose = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
### vytvor_uzivatele.yml
|
|
||||||
|
|
||||||
```
|
|
||||||
---
|
|
||||||
- hosts: all
|
|
||||||
become: yes
|
|
||||||
tasks:
|
|
||||||
- name: Add user "novyuzivatel"
|
|
||||||
user:
|
|
||||||
name: novyuzivatel
|
|
||||||
shell: /bin/bash
|
|
||||||
create_home: yes
|
|
||||||
```
|
|
||||||
|
|
||||||
### hosts (inventory for manual run)
|
|
||||||
|
|
||||||
```
|
|
||||||
[kube]
|
|
||||||
kube01 ansible_host=127.0.0.1 ansible_port=2222 ansible_user=vagrant ansible_ssh_private_key_file=.vagrant/machines/kube01/vmware_fusion/private_key
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Summary
|
|
||||||
|
|
||||||
- **Automatic:** Run `vagrant up` (or `vagrant provision`) and everything will be handled automatically.
|
|
||||||
- **Manual:** First run `vagrant up`, then run `ansible-playbook -i hosts vytvor_uzivatele.yml`.
|
|
||||||
|
|
||||||
This setup allows you to easily manage your VM and automate tasks using both Vagrant and Ansible.
|
|
||||||
```
|
|
||||||
Vendored
+7
-13
@@ -1,17 +1,11 @@
|
|||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
config.vm.define "kube01" do |kube01|
|
config.vm.define "node01" do |node|
|
||||||
kube01.vm.box = "bento/ubuntu-22.04"
|
node.vm.box = "bento/ubuntu-22.04"
|
||||||
kube01.vm.hostname = "kube01"
|
node.vm.provider "parallels" do |prl|
|
||||||
|
prl.name = "node01" # Set the visible name of the VM in Parallels
|
||||||
kube01.vm.provider "vmware_fusion" do |v|
|
prl.memory = 4096 # Allocate 4 GB of RAM (in MB)
|
||||||
v.gui = false
|
prl.cpus = 4 # Allocate 4 CPU cores
|
||||||
v.memory = 2048
|
prl.check_guest_tools = true # Enable automatic checking/updating of Parallels Tools in the guest
|
||||||
v.cpus = 2
|
|
||||||
end
|
|
||||||
|
|
||||||
kube01.vm.provision "ansible" do |ansible|
|
|
||||||
ansible.playbook = "vytvor_uzivatele.yml"
|
|
||||||
ansible.verbose = true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
[kube]
|
|
||||||
kube01 ansible_host=127.0.0.1 ansible_port=2222 ansible_user=vagrant ansible_ssh_private_key_file=.vagrant/machines/kube01/vmware_fusion/private_key
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
- hosts: all
|
|
||||||
become: yes
|
|
||||||
tasks:
|
|
||||||
- name: Přidat uživatele "novyuzivatel"
|
|
||||||
user:
|
|
||||||
name: novyuzivatel
|
|
||||||
shell: /bin/bash
|
|
||||||
create_home: yes
|
|
||||||
Reference in New Issue
Block a user