RockyLinuxへのAWX環境構築
- 今回、AnsibleをWebGUIで操作するソフトウェアとしてOSSで提供されているAWXを構築する。
- 環境
- OS:Rocky Linux release 9.6 (Blue Onyx)
- VMはProxmox上に構築
- インストールするAWXバージョン:2.19.1
- 端末のIP:192.168.100.7
事前準備
- パッケージの最新化と後程必要になるパッケージをインストール
- ファイヤーウォールの穴あけ
dnf update -y dnf install git make -y firewall-cmd --permanent --add-port=8000/tcp firewall-cmd --reload
Dockerインストール
- root権限で実行
- リポジトリを追加しインストール
- 起動およびOS再起動時の自動実行を適用
dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo dnf install docker-ce docker-ce-cli containerd.io -y systemctl start docker systemctl enable docker
minikubeインストール
-
root権限で実行
-
minikubeのRPMファイルを公式サイトに掲載されているURLからダウンロードしインストール
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-latest.x86_64.rpm rpm -Uvh minikube-latest.x86_64.rpm -
minikubeの起動はオプションでdockerドライバーを指定する
-
ちなみにroot権限でminikubeを起動すると以下のようにエラーになる
[root@localhost ~]# minikube start --driver docker 😄 minikube v1.36.0 on Rocky 9.6 (kvm/amd64) ✨ Using the docker driver based on user configuration 🛑 The "docker" driver should not be used with root privileges. If you wish to continue as root, use --force. 💡 If you are running minikube within a VM, consider using --driver=none: 📘 https://minikube.sigs.k8s.io/docs/reference/drivers/none/ ❌ Exiting due to DRV_AS_ROOT: The "docker" driver should not be used with root privileges. -
そこで一般ユーザにdockerの権限を付ける
-
ここでは新規ユーザとして「hoge」ユーザを作り、権限を付与する
adduser hoge usermod -aG docker hoge -
一般ユーザ「hoge」に移り、minikubeを起動する
su - hoge minikube start --driver=docker -
起動成功
[hoge@localhost ~]$ minikube start --driver=docker 😄 minikube v1.36.0 on Rocky 9.6 (kvm/amd64) ✨ Using the docker driver based on user configuration 📌 Using Docker driver with root privileges 👍 Starting "minikube" primary control-plane node in "minikube" cluster 🚜 Pulling base image v0.0.47 ... 💾 Downloading Kubernetes v1.33.1 preload ... > preloaded-images-k8s-v18-v1...: 347.04 MiB / 347.04 MiB 100.00% 11.49 M > gcr.io/k8s-minikube/kicbase...: 502.26 MiB / 502.26 MiB 100.00% 9.94 Mi 🔥 Creating docker container (CPUs=2, Memory=2200MB) ... 🐳 Preparing Kubernetes v1.33.1 on Docker 28.1.1 ... ▪ Generating certificates and keys ... ▪ Booting up control plane ... ▪ Configuring RBAC rules ... 🔗 Configuring bridge CNI (Container Networking Interface) ... 🔎 Verifying Kubernetes components... ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5 🌟 Enabled addons: storage-provisioner, default-storageclass 💡 kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A' 🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default -
起動が確認できたら一旦、minikubeを止める
minikube stop -
OS再起動後でもminikubeを自動起動させるためにsystemdに登録する
-
root権限で実施する
vi /etc/systemd/system/minikube.service- vi /etc/systemd/system/minikube.service
[Unit] Description=Minikube Cluster After=containerd.service docker.service [Service] Type=oneshot ExecStart=/usr/bin/minikube start --driver=docker RemainAfterExit=true ExecStop=/usr/bin/minikube stop StandardOutput=journal User=hoge Group=docker [Install] WantedBy=multi-user.target
systemctl daemon-reload systemctl start minikube.service systemctl status minikube.service systemctl enable minikube.service - vi /etc/systemd/system/minikube.service
- 参考資料
kubectlインストール
- minikubeをコマンドラインで制御するためにkubectlをインストールする
- kubernetesの公式サイトのドキュメントを参照し、curlを使用してkubectlのバイナリをインストールする
- root権限で実施
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" mv kubectl /usr/local/bin/ chmod +x /usr/local/bin/kubectl
- 実行結果
[root@localhost ~]# curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 138 100 138 0 0 610 0 --:--:-- --:--:-- --:--:-- 613 100 57.3M 100 57.3M 0 0 18.2M 0 0:00:03 0:00:03 --:--:-- 20.3M [root@localhost ~]# mv kubectl /usr/local/bin/ [root@localhost ~]# chmod +x /usr/local/bin/kubectl [root@localhost ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION minikube Ready control-plane 21m v1.33.1
- 一般ユーザ「hoge」に移動し、ノード情報を取得してみる。
[hoge@localhost]$ kubectl get nodes NAME STATUS ROLES AGE VERSION minikube Ready control-plane 21m v1.33.1
AWX構築
- 以降は一般ユーザ「hoge」で実施する
- gitからリポジトリをダウンロード
git clone https://github.com/ansible/awx-operator.git cd awx-operator/ git tag git checkout tags/2.19.1 export VERSION=2.19.1 make deploy - awx-demo.yml修正
--- apiVersion: awx.ansible.com/v1beta1 kind: AWX metadata: name: awx-demo spec: service_type: nodeport - kubectlのコンテキストをnamespace:awxに変更
kubectl config set-context --current --namespace=awx- 以下の応答が返ってくる
Context "minikube" modified.
- 以下の応答が返ってくる
- kustomization.yml修正
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.19.1 - awx-demo.yml # Set the image tags to match the git version from above images: - name: quay.io/ansible/awx-operator newTag: 2.19.1 # Specify a custom namespace in which to install AWX namespace: awx - 起動
kubectl apply -k .- 実行結果
[newUser@localhost awx-operator]$ kubectl apply -k . namespace/awx unchanged customresourcedefinition.apiextensions.k8s.io/awxbackups.awx.ansible.com unchanged customresourcedefinition.apiextensions.k8s.io/awxmeshingresses.awx.ansible.com unchanged customresourcedefinition.apiextensions.k8s.io/awxrestores.awx.ansible.com unchanged customresourcedefinition.apiextensions.k8s.io/awxs.awx.ansible.com unchanged serviceaccount/awx-operator-controller-manager unchanged role.rbac.authorization.k8s.io/awx-operator-awx-manager-role configured role.rbac.authorization.k8s.io/awx-operator-leader-election-role unchanged clusterrole.rbac.authorization.k8s.io/awx-operator-metrics-reader unchanged clusterrole.rbac.authorization.k8s.io/awx-operator-proxy-role unchanged rolebinding.rbac.authorization.k8s.io/awx-operator-awx-manager-rolebinding unchanged rolebinding.rbac.authorization.k8s.io/awx-operator-leader-election-rolebinding unchanged clusterrolebinding.rbac.authorization.k8s.io/awx-operator-proxy-rolebinding unchanged configmap/awx-operator-awx-manager-config unchanged service/awx-operator-controller-manager-metrics-service unchanged deployment.apps/awx-operator-controller-manager unchanged awx.awx.ansible.com/awx-demo created
- 実行結果
- 試しにPodが起動したか確認
[newUser@localhost awx-operator]$ kubectl get pods NAME READY STATUS RESTARTS AGE awx-demo-migration-24.6.1-fxsp7 0/1 Completed 0 6m36s awx-demo-postgres-15-0 1/1 Running 0 7m13s awx-demo-task-6d97bd5848-p2ppj 4/4 Running 0 6m54s awx-demo-web-cdd6bf794-cglct 3/3 Running 0 6m56s awx-operator-controller-manager-58b7c97f4b-76zff 2/2 Running 0 13m [newUser@localhost awx-operator]$ kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE awx-demo-postgres-15 ClusterIP None <none> 5432/TCP 7m20s awx-demo-service NodePort 10.102.158.93 <none> 80:32533/TCP 7m5s awx-operator-controller-manager-metrics-service ClusterIP 10.101.119.209 <none> 8443/TCP 3d - GUIにログインするための初期パスワードを取得
kubectl get secret awx-demo-admin-password -o jsonpath="{.data.password}" | base64 --decode ; echo- 実行結果(こんな感じでパスワードが表示される)
[newUser@localhost awx-operator] kubectl get secret awx-demo-admin-password -o jsonpath="{.data.password}" | base64 --decode ; echo 1dn*******************Q3Ry
- 実行結果(こんな感じでパスワードが表示される)
- ポートフォワード設定
- NW上の他端末からGUIへアクセスするためにポートフォワードの設定を行う
- またバックグラウンド処理させてターミナルが切断されてもフォワーディングがされるようにする
nohup kubectl port-forward svc/awx-demo-service --address 0.0.0.0 8000:80 &> portforward.log &
- 参考資料
AWXにログインする
-
http://192.168.100.7:8000
- ユーザ名:admin
- パスワード:上記で取得したパスワード
- ログイン成功
- 必要に応じて(adminパスワードの変更)
- 左メニュのアクセス欄にあるユーザを選択
- adminを選択
- 編集を選択
- 「パスワード」「パスワード確認」を入力し保存