Skip to content

Instantly share code, notes, and snippets.

@cdot65
Last active May 1, 2024 07:01
Show Gist options
  • Save cdot65/e1b853bd4785c57454fc11a2d2806891 to your computer and use it in GitHub Desktop.
Save cdot65/e1b853bd4785c57454fc11a2d2806891 to your computer and use it in GitHub Desktop.
Install Ansible AWX on Rancher k3s

up-and-running-ansible-awx

A reference for spinning up Ansible AWX on top of a Kubernetes environment

k3s install

Install k3s with bash script

curl -sfL https://get.k3s.io | sh -

change permissions on k3s config file

sudo chown $USER:$USER /etc/rancher/k3s/k3s.yaml

validate status

kubectl get nodes

install Kustomize

Start with installing kustomize

curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"  | bash
sudo mv kustomize /usr/local/bin/

deploy AWX operator

create kustomize instructions for installing operator

cd /var/tmp/
vim kustomization.yaml

Make sure to specify a release version, I will be using 2.2.1 in this example:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  # Find the latest tag here: https://github.com/ansible/awx-operator/releases
  - github.com/ansible/awx-operator/config/default?ref=2.2.1

# Set the image tags to match the git version from above
images:
  - name: quay.io/ansible/awx-operator
    newTag: 2.2.1

# Specify a custom namespace in which to install AWX
namespace: awx

install operator

kustomize build . | kubectl apply -f -

wait for operator to be installed and running

kubectl get pods -n awx

create awx.yaml

vim awx.yaml
---
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
  name: awx
spec:
  service_type: nodeport
  # default nodeport_port is 30080
  nodeport_port: 30080

add axw.yaml to kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  # Find the latest tag here: https://github.com/ansible/awx-operator/releases
  - github.com/ansible/awx-operator/config/default?ref=2.2.1
  - awx.yaml

# Set the image tags to match the git version from above
images:
  - name: quay.io/ansible/awx-operator
    newTag: 2.2.1

# Specify a custom namespace in which to install AWX
namespace: awx

kick off job to install awx

kustomize build . | kubectl apply -f -

watch the glorious logs

kubectl logs -f deployments/awx-operator-controller-manager -c awx-manager --namespace awx

grab password

kubectl get secret awx-admin-password -o jsonpath="{.data.password}" --namespace awx | base64 --decode

AWX setup

Credientials

  • SCM
  • Network
  • Vault

Projects

AWX Hello World

git@github.com:cdot65/Ansible-AWX-Hello-World.git

PAN Hello World

git@github.com:cdot65/pan-ansible-hello-world.git

Execution Environments

name: "Palo Alto Networks"
image: ghcr.io/cdot65/ansible-ee-paloaltonetworks:dev

Inventories

name: "Firewalls"
Group: "firewalls"
Hosts:
    - aus-vfw-01:
        ansible_host: 10.60.0.41
    - hdq-vfw-01:
        ansible_host: 10.60.0.41

Templates

Hello World: AWX

name: "Hello World: AWX"
playbook: "hello.yaml"
ee: none
inventory: "demo"

Hello World: PAN-OS

name: "Hello World: PAN-OS"
playbook: "ansible/panos.yaml"
ee: "palo alto networks"
inventory: "Firewalls"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment