Ansible Playbook 실습 - Ansible AWX - Ansible AWX 설치 자동화 - 설계 1 > Ansible 자료실

본문 바로가기
사이트 내 전체검색

Ansible 자료실

실습 Ansible Playbook 실습 - Ansible AWX - Ansible AWX 설치 자동화 - 설계 1

페이지 정보

profile_image
작성자 꿈꾸는여행자
댓글 0건 조회 3,020회 작성일 25-02-20 18:00

본문

안녕하세요.

 

꿈꾸는여행자입니다.

 

 

Ansible을 통한 Playbook을 활용에 대해서 Ansible AWX 구성 자동화 방안을 생각해 보았습니다.

 

해당 항목들을 설계 및 구현 해보는 과정을 진행하고자 합니다. 

 

이번 항목에서는 다음 내용을 기준으로 

설계해 보겠습니다. 

 

 

1. Ansible AWX Operator 설치를 위한 Ansible 기반 자동화

 

 

감사합니다. 

 

> 아래 

 

# **Ansible AWX Operator 2.19.1 기반 전체 배포 프로젝트 구조**


```

.

├── clearup.yml

├── files

│   └── awx-operator.tar.gz           # 로컬에서 준비된 awx-operator 파일

├── group_vars

│   └── all.yml

├── install-awx-operator.yml

├── inventory.ini

├── playbook.yml

├── prepare.yml

├── README.md

└── roles

    ├── clearup

    ├── prepare_awx_operator

    ├── copy_offline_package

    ├── copy_awx_images               # 추가된 역할: K3s 컨테이너 이미지 복사

    ├── install_awx_operator

    └── configure_awx

```


---


###️ **1. `inventory.ini` (인벤토리 설정)**

```ini

[all]

localhost ansible_connection=local ansible_user=lds ansible_become=true ansible_become_method=sudo


[k3s_nodes]

node1 ansible_host=192.168.10.22 ansible_user=lds ansible_become=true ansible_become_method=sudo ansible_ssh_common_args='-o StrictHostKeyChecking=no'

```


---


###  **2. `install-awx-operator.yml` (메인 플레이북)**

```yaml

---

- name: Deploy AWX using awx-operator (2.19.1) on Rocky Linux 8

  hosts: all

  become: true

  gather_facts: true


  roles:

    - role: prepare_awx_operator

    - role: copy_offline_package

    - role: copy_awx_images

    - role: install_awx_operator

    - role: configure_awx

```


---


### ️ **3. `group_vars/all.yml` (공통 변수 설정)**

```yaml

awx_namespace: "awx"

awx_admin_user: "admin"

awx_admin_password: "password"

awx_service_type: "NodePort"

awx_hostname: "awx.localdomain"

awx_operator_version: "2.19.1"

awx_operator_local_path: "files/awx-operator.tar.gz"

awx_operator_remote_path: "/opt/awx-operator.tar.gz"

awx_operator_extract_path: "/opt/awx-operator"

k3s_image_path: "/var/lib/rancher/k3s/agent/images"

awx_operator_images:

  - quay.io/ansible/awx-operator:2.19.1

  - quay.io/ansible/awx:21.10.0

  - docker.io/library/postgres:13

  - redis:6

```


---


###  **4. `roles/prepare_awx_operator/tasks/main.yml` (사전 준비 작업)**

```yaml

---

- name: Install essential packages

  dnf:

    name:

      - git

      - python3-pip

      - kubectl

      - helm

    state: present


- name: Install kustomize

  shell: |

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

    mv kustomize /usr/local/bin/

  args:

    creates: /usr/local/bin/kustomize

```


---


###  **5. `roles/copy_offline_package/tasks/main.yml` (로컬 파일 준비 및 원격 복사)**

```yaml

---

- name: Ensure destination directory exists

  file:

    path: "{{ awx_operator_extract_path }}"

    state: directory

    mode: '0755'


- name: Copy AWX operator package to remote host

  copy:

    src: "{{ awx_operator_local_path }}"

    dest: "{{ awx_operator_remote_path }}"

    mode: '0644'


- name: Extract AWX operator package

  unarchive:

    src: "{{ awx_operator_remote_path }}"

    dest: "{{ awx_operator_extract_path }}"

    remote_src: yes

```


---


###  **6. `roles/copy_awx_images/tasks/main.yml` (AWX 관련 컨테이너 이미지 복사)**

```yaml

---

- name: Download specified AWX Operator images

  shell: |

    for img in {{ awx_operator_images | join(' ') }}; do

      ctr -n k8s.io images pull $img;

    done

  args:

    executable: /bin/bash


- name: Save downloaded images to tar files

  shell: |

    mkdir -p /tmp/awx-images

    for img in $(ctr -n k8s.io images ls -q); do

      ctr -n k8s.io images export /tmp/awx-images/$(basename $img).tar $img;

    done


- name: Copy image tar files to K3s image directory

  shell: |

    cp /tmp/awx-images/*.tar {{ k3s_image_path }}


- name: Import images into K3s containerd

  shell: |

    for tar in {{ k3s_image_path }}/*.tar; do

      ctr -n k8s.io images import $tar;

    done

```


---


###  **7. `roles/install_awx_operator/tasks/main.yml` (AWX Operator 설치)**

```yaml

---

- name: Deploy awx-operator

  shell: |

    kustomize build . | kubectl apply -f -

  args:

    chdir: "{{ awx_operator_extract_path }}"


- name: Wait for awx-operator deployment

  shell: |

    kubectl rollout status deployment/awx-operator-controller-manager -n {{ awx_namespace }}

  retries: 10

  delay: 30

  register: rollout_status

  until: rollout_status.rc == 0

```


---


### ️ **8. `roles/configure_awx/tasks/main.yml` (AWX 초기 구성)**

```yaml

---

- name: Create AWX deployment manifest

  copy:

    dest: "{{ awx_operator_extract_path }}/awx-deployment.yaml"

    content: |

      apiVersion: awx.ansible.com/v1beta1

      kind: AWX

      metadata:

        name: awx

        namespace: {{ awx_namespace }}

      spec:

        service_type: {{ awx_service_type }}

        ingress_type: none

        hostname: {{ awx_hostname }}

        admin_user: {{ awx_admin_user }}

        admin_password: {{ awx_admin_password }}


- name: Apply AWX deployment

  shell: |

    kubectl apply -f awx-deployment.yaml -n {{ awx_namespace }}

  args:

    chdir: "{{ awx_operator_extract_path }}"


- name: Wait for AWX pods to be ready

  shell: |

    kubectl wait --for=condition=ready pod -l "app.kubernetes.io/name=awx" -n {{ awx_namespace }} --timeout=600s


- name: Display AWX access information

  debug:

    msg: "AWX UI available at http://{{ awx_hostname }} with user '{{ awx_admin_user }}'"

```


---


 **전체 변경 사항 요약**

- **Operator 버전 2.19.1**에 맞춘 컨테이너 이미지 목록(`awx_operator_images`)을 정의

- **파일 준비 → 원격 복사 → 이미지 다운로드 및 등록 → AWX Operator 설치 → AWX 초기 구성**의 전체 배포 흐름 제공

- **K3s 오프라인 환경 지원**을 위한 최적화된 플레이북 설계



 

댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

사이트 정보

회사명 : (주)리눅스데이타시스템
대표이사 : 정정모
본사 : 강남구 봉은사로 114길 40 홍선빌딩 2층
- tel : 02-6207-1160
대전지사 : 유성구 노은로174 도원프라자 5층
- tel : 042-331-1161

접속자집계

오늘
2,421
어제
2,585
최대
8,445
전체
2,034,631
Copyright © www.linuxdata.org All rights reserved.