├── README.md ├── apache-server ├── inventory │ └── groups │ │ └── all ├── playbook.yml └── roles │ └── apache │ ├── handlers │ └── apache.yml │ └── tasks │ └── apache.yml └── hello-world ├── inventory └── groups │ └── all └── playbook.yml /README.md: -------------------------------------------------------------------------------- 1 | # JetPorch Examples 2 | 3 | This repository contains some examples and guides I wrote to learn and test out [JetPorch](https://www.jetporch.com), a fast and robust infrastructure automation tool. 4 | 5 | ## Installing JetPorch 6 | 7 | Currently, JetPorch is in 'Tech Preview' release, so no official packages are available. You need to [follow the source install directions](https://www.jetporch.com/basics/installing-from-source) to install JetPorch on your control machine. 8 | 9 | On my Mac, that meant: 10 | 11 | 1. Install Rust: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` 12 | 1. Install dependencies: `brew install gcc openssl` 13 | 1. Clone JetPorch: `git clone https://github.com/jetporch/jetporch.git` 14 | 1. Build JetPorch: `cd jetporch && make` 15 | 1. Add the `jetp` binary to your `$PATH` so you can execute it: `export PATH=$PATH:$(pwd)/target/release/` 16 | 17 | > Note: If you get an error like `command not found: cargo` when you build JetPorch, make sure you have added `~/.cargo/bin` to your `$PATH`. 18 | 19 | Test to make sure JetPorch is working: 20 | 21 | ``` 22 | $ jetp --version 23 | 24 | ┌─────┬─────────────────────────────────────────────┐ 25 | │jetp │http://www.jetporch.com/ │ 26 | │ │(C) Michael DeHaan + contributors, 2023 │ 27 | │ │ │ 28 | │build│79de310f5dfd0d0ab8e30171ed411b9919e4b366@main│ 29 | │ │Thu Oct 5 07:52:19 CDT 2023 │ 30 | ├─────┼─────────────────────────────────────────────┤ 31 | │ │usage: jetp [flags] │ 32 | └─────┴─────────────────────────────────────────────┘ 33 | ``` 34 | 35 | ## Setting up test VMs 36 | 37 | TODO: See [this comment](https://github.com/geerlingguy/ansible-for-devops/issues/404#issuecomment-1747846798). 38 | 39 | ### UTM 40 | 41 | Currently the easiest way to get a local Linux VM up and running with SSH access from the host on my Mac is via UTM. 42 | 43 | Assuming you have [Homebrew installed]() and have a copy of the [Ubuntu 22.04 Server for arm64 ISO](), here are the steps to build a VM for JetPorch testing: 44 | 45 | 1. `brew install --cask utm` 46 | 1. Link the `utmctl` CLI utility somewhere you can use it: `sudo ln -sf /Applications/UTM.app/Contents/MacOS/utmctl /usr/local/bin/utmctl` 47 | 1. Open UTM, create a new VM, and select the Ubuntu Server ISO. 48 | 1. Follow the Ubuntu server setup wizard and get it set up with a user account you'd like to use. 49 | 1. Once installation is complete, make sure you eject the ISO and reboot. 50 | 51 | Note: Currently sudo password support is missing in JetPorch. For now, you need to run `visudo` and make sure the user account you're using for access has passwordless sudo enabled. 52 | 53 | On an Ubuntu system, this means you need to run `visudo` and make sure the `%sudo` line looks like: 54 | 55 | ``` 56 | %sudo ALL=(ALL) NOPASSWD:ALL 57 | ``` 58 | 59 | Run the command `ip a` to find the IP address of your UTM Linux VM, and use that in your inventory file to connect to the VM. (In my case, `192.168.64.3`.) 60 | 61 | ## License 62 | 63 | GPLv3 or later 64 | 65 | ## Author 66 | 67 | [Jeff Geerling](https://www.jeffgeerling.com), author of [JetPorch Automation](https://www.jetporchautomation.com). 68 | -------------------------------------------------------------------------------- /apache-server/inventory/groups/all: -------------------------------------------------------------------------------- 1 | hosts: 2 | - 192.168.64.3 3 | -------------------------------------------------------------------------------- /apache-server/playbook.yml: -------------------------------------------------------------------------------- 1 | - name: Install and configure Apache HTTP Server. 2 | groups: 3 | - all 4 | 5 | sudo: root 6 | 7 | roles: 8 | - {role: redis, vars: {redis_port: 5000}, tags: ['redis']} 9 | 10 | tasks: 11 | 12 | - !echo 13 | msg: "Apache is ready to go!" 14 | -------------------------------------------------------------------------------- /apache-server/roles/apache/handlers/apache.yml: -------------------------------------------------------------------------------- 1 | # TODO: Parameterize the service name. 2 | - !sd_service 3 | service: apache2 4 | restart: true 5 | with: 6 | subscribe: restart apache 7 | -------------------------------------------------------------------------------- /apache-server/roles/apache/tasks/apache.yml: -------------------------------------------------------------------------------- 1 | - !facts 2 | {} 3 | 4 | - !echo 5 | msg: "OS distro detected={{ jet_os_flavor }}" 6 | 7 | - !dnf 8 | package: httpd 9 | with: 10 | condition: (eq jet_os_flavor "EL") 11 | 12 | - !apt 13 | package: apache2 14 | with: 15 | condition: (eq jet_os_flavor "Debian") 16 | 17 | # TODO: Parameterize the filesystem path, username. 18 | - !template 19 | src: apache.conf.hb 20 | dest: /etc/apache/apache.conf 21 | attributes: 22 | owner: redis 23 | group: redis 24 | mode: 0o640 25 | and: 26 | notify: restart apache 27 | 28 | # TODO: Parameterize the service name. 29 | - !sd_service 30 | service: apache2 31 | started: true 32 | enabled: true 33 | -------------------------------------------------------------------------------- /hello-world/inventory/groups/all: -------------------------------------------------------------------------------- 1 | hosts: 2 | - 192.168.64.3 3 | -------------------------------------------------------------------------------- /hello-world/playbook.yml: -------------------------------------------------------------------------------- 1 | - name: sample playbook 2 | 3 | groups: 4 | - all 5 | 6 | sudo: root 7 | 8 | tasks: 9 | 10 | - !shell 11 | cmd: echo hi 12 | 13 | - !apt 14 | package: redis 15 | --------------------------------------------------------------------------------