IaC/Configuration Management

Ansible 활용 - ansible-galaxy에 Role/Collection 업로드

Somaz 2023. 12. 25. 00:26
728x90
반응형

Overview

Ansible-Galaxy 에 대해서 공부해보려고 한다.

출처 : https://danuka-praneeth.medium.com/ansible-roles-and-ansible-galaxy-b224f4693cd4

 


Ansible 설치

pip install ansible
yum install ansible -y
apt install ansible
brew install ansible

출처 : https://danuka-praneeth.medium.com/ansible-roles-and-ansible-galaxy-b224f4693cd4

 

 


Ansible Galaxy란?

Ansible Galaxy는 Ansible 콘텐츠를 공유하고 관리하기 위한 저장소이다. 이는 사용자가 Ansible에 대한 역할과 컬렉션을 찾고, 다운로드하고, 공유할 수 있는 플랫폼을 제공한다.


 

Role이란?

Ansible의 역할은 특정 작업 또는 작업 집합을 자동화하기 위해 일련의 작업, 변수, 파일 및 핸들러를 캡슐화하는 모듈식 단위이다.

역할은 재사용이 가능하며 다양한 플레이북에서 공유될 수 있다.

복잡한 플레이북을 더 작고 재사용 가능한 구성 요소로 나누는 데 사용된다. 이렇게 하면 플레이북을 더 쉽게 관리하고 업데이트할 수 있다. 역할에는 일반적으로 `tasks, handlers, files, templates, vars 및 defaults`와 같은 디렉터리가 포함되며, 각각은 역할에서 특정 목적을 수행한다.

 

Directory 구조

├── LICENSE
├── README.md
├── defaults
│   └── main.yml
├── files
├── handlers
│   └── main.yml
├── meta
│   └── main.yml
├── molecule
│   └── default
│       ├── converge.yml
│       ├── molecule.yml
│       └── verify.yml
├── tasks
│   └── main.yml
├── templates
│   └── bashrc_extensions.j2
└── vars
    └── main.yml

 

 

Role 생성

해당 명령어를 사용하여 role을 간단하게 생성할 수 있다. 디렉토리 구조도 만들어준다. helm init 명령어와 유사하다.

ansible-galaxy role init test-somaz
- Role test-somaz was created successfully

# Directory Structure
├── README.md
├── defaults
│   └── main.yml
├── files
├── handlers
│   └── main.yml
├── meta
│   └── main.yml
├── tasks
│   └── main.yml
├── templates
├── tests
│   ├── inventory
│   └── test.yml
└── vars
    └── main.yml

 

 


 

Collection이란?

컬렉션은 플레이북, 역할, 모듈 및 플러그인을 포함할 수 있는 Ansible 콘텐츠의 배포 형식이다.

컬렉션을 사용하면 사용자는 자신의 Ansible 콘텐츠나 다른 사람의 콘텐츠를 패키징하고 배포할 수 있다. 컬렉션은 Ansible 콘텐츠를 번들링, 공유 및 설치하는 방법을 제공한다. 이를 통해 Ansible 콘텐츠의 종속성 및 버전 관리를 더 쉽게 관리할 수 있다.

컬렉션의 루트에는 컬렉션 메타데이터를 정의하는 `galaxy.yml` 파일이 포함되어 있으며 콘텐츠를 `roles, playbooks, plugins` 등과 같은 디렉터리로 구성한다.

 

Directory 구조

├── LICENSE
├── README.md
├── galaxy.yml
├── group_vars
│   └── all
│       └── vars.yml
├── meta
│   └── runtime.yml
├── molecule
│   └── default
│       ├── converge.yml
│       ├── molecule.yml
│       └── verify.yml
├── roles
│   ├── install_helm
│   │   ├── README.md
│   │   ├── meta
│   │   │   └── main.yml
│   │   └── tasks
│   │       └── main.yml
│   ├── install_krew
│   │   ├── README.md
│   │   ├── meta
│   │   │   └── main.yml
│   │   └── tasks
│   │       └── main.yml
│   ├── install_krew_plugins
│   │   ├── README.md
│   │   ├── meta
│   │   │   └── main.yml
│   │   └── tasks
│   │       └── main.yml
│   ├── install_kubectl
│   │   ├── README.md
│   │   ├── meta
│   │   │   └── main.yml
│   │   └── tasks
│   │       └── main.yml
│   ├── install_kustomize
│   │   ├── README.md
│   │   ├── meta
│   │   │   └── main.yml
│   │   └── tasks
│   │       └── main.yml
│   ├── install_packer
│   │   ├── README.md
│   │   ├── meta
│   │   │   └── main.yml
│   │   └── tasks
│   │       └── main.yml
│   ├── install_pulumi
│   │   ├── README.md
│   │   ├── meta
│   │   │   └── main.yml
│   │   └── tasks
│   │       └── main.yml
│   ├── install_terraform
│   │   ├── README.md
│   │   ├── meta
│   │   │   └── main.yml
│   │   └── tasks
│   │       └── main.yml
│   ├── install_vagrant
│   │   ├── README.md
│   │   ├── meta
│   │   │   └── main.yml
│   │   └── tasks
│   │       └── main.yml
│   └── setup_bashrc
│       ├── README.md
│       ├── handlers
│       │   └── main.yml
│       ├── meta
│       │   └── main.yml
│       └── tasks
│           └── main.yml
└── templates
    └── bashrc_extensions.j2

38 directories, 40 files

 

Collection 생성

Ansible Galaxy에서 컬렉션을 생성할 때 컬렉션 이름은 `<namespace>.<collection>` 형식을 따라야한다. 그리고 자신의 `namespace` 안에 컬렉션 디렉토리가 생성된다.

# Error
ansible-galaxy collection init test_somaz
ERROR! Invalid collection name 'test_somaz', name must be in the format <namespace>.<collection>.
Please make sure namespace and collection name contains characters from [a-zA-Z0-9_] only.

# 
ansible-galaxy collection init somaz94.test_somaz
- Collection somaz94.test_somaz was created successfully

# Directory Structure
somaz94/
└── test_somaz
    ├── README.md
    ├── docs
    ├── galaxy.yml
    ├── plugins
    │   └── README.md
    └── roles

4 directories, 3 files

 


 

Ansible Role / Collection 업로드 및 삭제

 


 

API Token 생성

Ansible Galaxy에서 Role 또는 Collection을 업로드 하려면 Token을 생성해야 한다.

`Collections - API Token - Token Load`

 

 


 

Ansible Role 업로드/삭제

 

업로드

ansible-galaxy import somaz94 ansible_kubectl_krew --token YOUR_API_TOKEN
Successfully submitted import request 2052090589176677512243288545243636178
running
role imported successfully

삭제

ansible-galaxy delete somaz94 ansible_kubectl_krew --token YOUR_API_TOKEN

 


 

Ansible Collection 업로드/삭제

Collection은 Role과 다르게 Build 작업도 해줘야 한다.

 

빌드

ansible-galaxy collection build
Created collection for somaz94.ansible_k8s_iac_tool at /home/somaz/PrivateWork/ansible-k8s-iac-tool/somaz94-ansible_k8s_iac_tool-1.1.5.tar.gz

 

업로드

ansible-galaxy collection publish /path/to/namespace-collection_name-version.tar.gz --api-key=YOUR_API_TOKEN

 

삭제

collection을 삭제할때도 ansible-galaxy 사이트로 가서 삭제해주면 된다.

 


 

Ansible Role / Collection 업로드 결과

 

Collection

collection은 올린지 2달밖에 되지 않았지만 벌써 Donwloads가 275이다.

 

 

 


 

Molecule를 활용한 Ansible Role / Collection Test

Molecule은 Ansible 역할을 개발하고 테스트하기 위해 설계된 오픈 소스 테스트 프레임워크이다. Ansible과 밀접하게 연관되어 있지만 Ansible에만 국한되는 것은 아니다. Molecule은 여러 인스턴스, 운영 체제 및 배포판을 사용한 테스트를 지원하고 다양한 테스트 프레임워크 및 CI/CD 플랫폼과 통합된다.

출처 : https://www.thoughtco.com/what-is-a-molecule-definition-examples-608506

 

 


 

 

Molecule로 Ansible Role / collection 테스트 예시

 

1. 설치

pip install molecule

 

Docker 드라이버를 사용할 경우

pip install molecule[docker]

 

 

2. 새 Role 및 Molecule 환경 초기화

molecule init role <role_name> -d docker
  • 여기서 `-d docker`는 Docker 드라이버를 사용하도록 Molecule에 지시한다.

 

3. 테스트 케이스 작성

molecule/default/converge.yml 파일을 수정하여 실제로 실행하려는 Ansible tasks를 추가하거나 수정한다.

 

 

4. 인스턴스 생성 및 구성

molecule create
  • 위의 명령은 molecule/default/molecule.yml에 지정된 플랫폼 및 이미지를 사용하여 테스트 인스턴스를 생성한다.

 

5. Role 실행

molecule converge
  • `molecule converge`는 `converge.yml`을 실행하여 role을 테스트 인스턴스에 적용한다.

 

6. 테스트 수행

Molecule은 테스트 프레임워크인 테스트 인프라를 포함하며, 이를 사용하여 `molecule/default/tests`에서 Ansible 코드의 결과를 검증할 수 있다.

molecule verify

 

7. 정리

테스트가 완료되면 사용한 인스턴스를 정리한다.

molecule destroy

 

 


 

Molecule 파일구조 및 Example

molecule를 사용해서, 간단히 Ansible Role Test를 해본다.

molecule
└── default
    ├── converge.yml
    ├── molecule.yml
    └── verify.yml

 

 

`converge.yml`

---
- name: Converge
  hosts: all
  become: true

  pre_tasks:
    - name: Include group_vars
      include_vars: ../../vars/main.yml

    - name: Add user somaz
      user:
        name: "{{ home_user }}"
        shell: /bin/bash
        createhome: yes

    - name: Update apt cache.
      apt: 
        update_cache: yes
      when: ansible_os_family == 'Debian'

    - name: Update yum cache.
      yum:
        update_cache: yes
      when: ansible_os_family == 'RedHat'

  roles:
    - role: ansible_kubectl_krew

  post_tasks:
    - name: Notify about .bashrc reload
      debug:
        msg: ".bashrc will be reloaded on the next session."
      changed_when: false

    - name: Set ownership for .krew directory
      file:
        path: "~{{ home_user }}/.krew"
        owner: "{{ home_user }}"
        group: "{{ home_user }}"
        recurse: yes
        state: directory

 

 

`molecule.yml`

---
dependency:
  name: galaxy
driver:
  name: docker
platforms:
  - name: ubuntu-instance
    image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest"
    command: "tail -f /dev/null"
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:ro
    privileged: true
    pre_build_image: true
  - name: centos-instance
    image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos8}-ansible:latest"
    command: "tail -f /dev/null"
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:ro
    privileged: true
    pre_build_image: true
provisioner:
  name: ansible
verifier:
  name: ansible

 

 

`verify.yml`

---
- name: Verify
  hosts: all
  tasks:
    - name: Include vars
      include_vars: ../../vars/main.yml

    - name: Check if kubectl is installed
      command: kubectl version --client
      register: kubectl_result
      failed_when: kubectl_result.rc != 0
      changed_when: false

    - name: Check if krew is installed
      command: "/home/{{ home_user }}/.krew/bin/kubectl-krew version"
      register: krew_result
      failed_when: krew_result.rc != 0
      changed_when: false

 

 

molecule 실행

 

`molecule create`

INFO     default scenario test matrix: dependency, create, prepare, converge
INFO     Performing prerun with role_name_check=0...
INFO     Set ANSIBLE_LIBRARY=/home/somaz/.cache/ansible-compat/5fac3f/modules:/home/somaz/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/somaz/.cache/ansible-compat/5fac3f/collections:/home/somaz/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/home/somaz/.cache/ansible-compat/5fac3f/roles:/home/somaz/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Using /home/somaz/.cache/ansible-compat/5fac3f/roles/somaz.ansible_kubectl_krew symlink to current repository in order to enable Ansible to find the role using its expected full name.
INFO     Running default > dependency
WARNING  Skipping, missing the requirements file.
WARNING  Skipping, missing the requirements file.
INFO     Running default > create
INFO     Sanity checks: 'docker'

PLAY [Create] ******************************************************************

TASK [Set async_dir for HOME env] **********************************************
ok: [localhost]

TASK [Log into a Docker registry] **********************************************
skipping: [localhost] => (item=None)
skipping: [localhost] => (item=None)
skipping: [localhost]

TASK [Check presence of custom Dockerfiles] ************************************
ok: [localhost] => (item={'command': 'tail -f /dev/null', 'image': 'geerlingguy/docker-ubuntu2004-ansible:latest', 'name': 'ubuntu-instance', 'pre_build_image': True, 'privileged': True, 'volumes': ['/sys/fs/cgroup:/sys/fs/cgroup:ro']})
ok: [localhost] => (item={'command': 'tail -f /dev/null', 'image': 'geerlingguy/docker-centos8-ansible:latest', 'name': 'centos-instance', 'pre_build_image': True, 'privileged': True, 'volumes': ['/sys/fs/cgroup:/sys/fs/cgroup:ro']})

TASK [Create Dockerfiles from image names] *************************************
skipping: [localhost] => (item={'command': 'tail -f /dev/null', 'image': 'geerlingguy/docker-ubuntu2004-ansible:latest', 'name': 'ubuntu-instance', 'pre_build_image': True, 'privileged': True, 'volumes': ['/sys/fs/cgroup:/sys/fs/cgroup:ro']})
skipping: [localhost] => (item={'command': 'tail -f /dev/null', 'image': 'geerlingguy/docker-centos8-ansible:latest', 'name': 'centos-instance', 'pre_build_image': True, 'privileged': True, 'volumes': ['/sys/fs/cgroup:/sys/fs/cgroup:ro']})

TASK [Synchronization the context] *********************************************
skipping: [localhost] => (item={'command': 'tail -f /dev/null', 'image': 'geerlingguy/docker-ubuntu2004-ansible:latest', 'name': 'ubuntu-instance', 'pre_build_image': True, 'privileged': True, 'volumes': ['/sys/fs/cgroup:/sys/fs/cgroup:ro']})
skipping: [localhost] => (item={'command': 'tail -f /dev/null', 'image': 'geerlingguy/docker-centos8-ansible:latest', 'name': 'centos-instance', 'pre_build_image': True, 'privileged': True, 'volumes': ['/sys/fs/cgroup:/sys/fs/cgroup:ro']})

TASK [Discover local Docker images] ********************************************
ok: [localhost] => (item={'changed': False, 'skipped': True, 'skip_reason': 'Conditional result was False', 'item': {'command': 'tail -f /dev/null', 'image': 'geerlingguy/docker-ubuntu2004-ansible:latest', 'name': 'ubuntu-instance', 'pre_build_image': True, 'privileged': True, 'volumes': ['/sys/fs/cgroup:/sys/fs/cgroup:ro']}, 'ansible_loop_var': 'item', 'i': 0, 'ansible_index_var': 'i'})
ok: [localhost] => (item={'changed': False, 'skipped': True, 'skip_reason': 'Conditional result was False', 'item': {'command': 'tail -f /dev/null', 'image': 'geerlingguy/docker-centos8-ansible:latest', 'name': 'centos-instance', 'pre_build_image': True, 'privileged': True, 'volumes': ['/sys/fs/cgroup:/sys/fs/cgroup:ro']}, 'ansible_loop_var': 'item', 'i': 1, 'ansible_index_var': 'i'})

TASK [Build an Ansible compatible image (new)] *********************************
skipping: [localhost] => (item=molecule_local/geerlingguy/docker-ubuntu2004-ansible:latest)
skipping: [localhost] => (item=molecule_local/geerlingguy/docker-centos8-ansible:latest)

TASK [Create docker network(s)] ************************************************

TASK [Determine the CMD directives] ********************************************
ok: [localhost] => (item={'command': 'tail -f /dev/null', 'image': 'geerlingguy/docker-ubuntu2004-ansible:latest', 'name': 'ubuntu-instance', 'pre_build_image': True, 'privileged': True, 'volumes': ['/sys/fs/cgroup:/sys/fs/cgroup:ro']})
ok: [localhost] => (item={'command': 'tail -f /dev/null', 'image': 'geerlingguy/docker-centos8-ansible:latest', 'name': 'centos-instance', 'pre_build_image': True, 'privileged': True, 'volumes': ['/sys/fs/cgroup:/sys/fs/cgroup:ro']})

TASK [Create molecule instance(s)] *********************************************
changed: [localhost] => (item=ubuntu-instance)
changed: [localhost] => (item=centos-instance)

TASK [Wait for instance(s) creation to complete] *******************************
FAILED - RETRYING: [localhost]: Wait for instance(s) creation to complete (300 retries left).
changed: [localhost] => (item={'failed': 0, 'started': 1, 'finished': 0, 'ansible_job_id': '971366258816.5257', 'results_file': '/home/somaz/.ansible_async/971366258816.5257', 'changed': True, 'item': {'command': 'tail -f /dev/null', 'image': 'geerlingguy/docker-ubuntu2004-ansible:latest', 'name': 'ubuntu-instance', 'pre_build_image': True, 'privileged': True, 'volumes': ['/sys/fs/cgroup:/sys/fs/cgroup:ro']}, 'ansible_loop_var': 'item'})
changed: [localhost] => (item={'failed': 0, 'started': 1, 'finished': 0, 'ansible_job_id': '311475436591.5284', 'results_file': '/home/somaz/.ansible_async/311475436591.5284', 'changed': True, 'item': {'command': 'tail -f /dev/null', 'image': 'geerlingguy/docker-centos8-ansible:latest', 'name': 'centos-instance', 'pre_build_image': True, 'privileged': True, 'volumes': ['/sys/fs/cgroup:/sys/fs/cgroup:ro']}, 'ansible_loop_var': 'item'})

PLAY RECAP *********************************************************************
localhost                  : ok=6    changed=2    unreachable=0    failed=0    skipped=5    rescued=0    ignored=0

 

 

`molecule converge`

PLAY [Converge] ****************************************************************

TASK [Gathering Facts] *********************************************************
ok: [ubuntu-instance]
ok: [centos-instance]

TASK [Include group_vars] ******************************************************
ok: [centos-instance]
ok: [ubuntu-instance]

TASK [Add user somaz] **********************************************************
changed: [ubuntu-instance]
changed: [centos-instance]

TASK [Update apt cache.] *******************************************************
skipping: [centos-instance]
changed: [ubuntu-instance]

TASK [Update yum cache.] *******************************************************
skipping: [ubuntu-instance]
ok: [centos-instance]

TASK [ansible_kubectl_krew : Get home directory of specific user] **************
ok: [ubuntu-instance]
ok: [centos-instance]

TASK [ansible_kubectl_krew : Update .bashrc for specific user] *****************
changed: [ubuntu-instance]
changed: [centos-instance]

TASK [ansible_kubectl_krew : Check if kubectl is installed] ********************
ok: [ubuntu-instance]
ok: [centos-instance]

TASK [ansible_kubectl_krew : Set kubectl_installed fact based on kubectl_check] ***
ok: [centos-instance]
ok: [ubuntu-instance]

TASK [ansible_kubectl_krew : Get installed kubectl version] ********************
skipping: [centos-instance]
skipping: [ubuntu-instance]

TASK [ansible_kubectl_krew : set_fact] *****************************************
skipping: [centos-instance]
skipping: [ubuntu-instance]

TASK [ansible_kubectl_krew : Add required tools (Debian/Ubuntu)] ***************
skipping: [centos-instance]
changed: [ubuntu-instance]

TASK [ansible_kubectl_krew : Retrieve the latest kubectl version] **************
ok: [ubuntu-instance]
ok: [centos-instance]

TASK [ansible_kubectl_krew : Download kubectl binary] **************************
changed: [centos-instance]
changed: [ubuntu-instance]

TASK [ansible_kubectl_krew : Install kubectl] **********************************
changed: [ubuntu-instance]
changed: [centos-instance]

TASK [ansible_kubectl_krew : Clean up the downloaded binary] *******************
changed: [ubuntu-instance]
changed: [centos-instance]

TASK [ansible_kubectl_krew : Check if krew is installed] ***********************
ok: [centos-instance]
ok: [ubuntu-instance]

TASK [ansible_kubectl_krew : Ensure git is installed RHEL/CentOS] **************
skipping: [ubuntu-instance]
changed: [centos-instance]

TASK [ansible_kubectl_krew : Download and Install krew] ************************
ok: [centos-instance]
ok: [ubuntu-instance]

TASK [ansible_kubectl_krew : Check if krew plugin is already installed] ********
ok: [centos-instance] => (item=ctx)
ok: [ubuntu-instance] => (item=ctx)
ok: [centos-instance] => (item=neat)
ok: [ubuntu-instance] => (item=neat)
ok: [centos-instance] => (item=ns)
ok: [ubuntu-instance] => (item=ns)

TASK [ansible_kubectl_krew : Install krew plugins for Debian/Ubuntu] ***********
skipping: [centos-instance] => (item=ctx)
skipping: [centos-instance] => (item=neat)
skipping: [centos-instance] => (item=ns)
ok: [ubuntu-instance] => (item=ctx)
ok: [ubuntu-instance] => (item=neat)
ok: [ubuntu-instance] => (item=ns)

TASK [ansible_kubectl_krew : Install krew plugins for RHEL/CentOS] *************
skipping: [ubuntu-instance] => (item=ctx)
skipping: [ubuntu-instance] => (item=neat)
skipping: [ubuntu-instance] => (item=ns)
ok: [centos-instance] => (item=ctx)
ok: [centos-instance] => (item=neat)
ok: [centos-instance] => (item=ns)

RUNNING HANDLER [ansible_kubectl_krew : reload bashrc] *************************
ok: [ubuntu-instance]
ok: [centos-instance]

TASK [Notify about .bashrc reload] *********************************************
ok: [centos-instance] => {
    "msg": ".bashrc will be reloaded on the next session."
}
ok: [ubuntu-instance] => {
    "msg": ".bashrc will be reloaded on the next session."
}

TASK [Set ownership for .krew directory] ***************************************
changed: [centos-instance]
changed: [ubuntu-instance]

PLAY RECAP *********************************************************************
centos-instance            : ok=20   changed=7    unreachable=0    failed=0    skipped=5    rescued=0    ignored=0
ubuntu-instance            : ok=20   changed=8    unreachable=0    failed=0    skipped=5    rescued=0    ignored=0

 

 

`molecule verify`

molecule verify
INFO     default scenario test matrix: verify
INFO     Performing prerun with role_name_check=0...
INFO     Set ANSIBLE_LIBRARY=/home/somaz/.cache/ansible-compat/5fac3f/modules:/home/somaz/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/somaz/.cache/ansible-compat/5fac3f/collections:/home/somaz/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/home/somaz/.cache/ansible-compat/5fac3f/roles:/home/somaz/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Using /home/somaz/.cache/ansible-compat/5fac3f/roles/somaz.ansible_kubectl_krew symlink to current repository in order to enable Ansible to find the role using its expected full name.
INFO     Running default > verify
INFO     Running Ansible Verifier
INFO     Sanity checks: 'docker'

PLAY [Verify] ******************************************************************

TASK [Gathering Facts] *********************************************************
ok: [ubuntu-instance]
ok: [centos-instance]

TASK [Include vars] ************************************************************
ok: [centos-instance]
ok: [ubuntu-instance]

TASK [Check if kubectl is installed] *******************************************
ok: [ubuntu-instance]
ok: [centos-instance]

TASK [Check if krew is installed] **********************************************
ok: [centos-instance]
ok: [ubuntu-instance]

PLAY RECAP *********************************************************************
centos-instance            : ok=4    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
ubuntu-instance            : ok=4    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

INFO     Verifier completed successfully.

 

 

`molecule destroy`

INFO     default scenario test matrix: dependency, cleanup, destroy
INFO     Performing prerun with role_name_check=0...
INFO     Set ANSIBLE_LIBRARY=/home/somaz/.cache/ansible-compat/5fac3f/modules:/home/somaz/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/somaz/.cache/ansible-compat/5fac3f/collections:/home/somaz/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/home/somaz/.cache/ansible-compat/5fac3f/roles:/home/somaz/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Using /home/somaz/.cache/ansible-compat/5fac3f/roles/somaz.ansible_kubectl_krew symlink to current repository in order to enable Ansible to find the role using its expected full name.
INFO     Running default > dependency
WARNING  Skipping, missing the requirements file.
WARNING  Skipping, missing the requirements file.
INFO     Running default > cleanup
WARNING  Skipping, cleanup playbook not configured.
INFO     Running default > destroy
INFO     Sanity checks: 'docker'

PLAY [Destroy] *****************************************************************

TASK [Set async_dir for HOME env] **********************************************
ok: [localhost]

TASK [Destroy molecule instance(s)] ********************************************
changed: [localhost] => (item=ubuntu-instance)
changed: [localhost] => (item=centos-instance)

TASK [Wait for instance(s) deletion to complete] *******************************
FAILED - RETRYING: [localhost]: Wait for instance(s) deletion to complete (300 retries left).
changed: [localhost] => (item=ubuntu-instance)
changed: [localhost] => (item=centos-instance)

TASK [Delete docker networks(s)] ***********************************************

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=2    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0

INFO     Pruning extra files from scenario ephemeral directory

 

 


Reference

https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html

https://danuka-praneeth.medium.com/ansible-roles-and-ansible-galaxy-b224f4693cd4

https://github.com/somaz94/ansible_kubectl_krew

https://github.com/somaz94/ansible-k8s-iac-tool

https://galaxy.ansible.com/

728x90
반응형