본문으로 바로가기
반응형

Ansible Tower CLI를 통해 웹 대시보드와 같이 Ansible Tower를 관리할 수 있다.

CLI Tools은 Tower Restful API에 명령을 보낸다.

 

 

1. tower-cli 설치

[root@ansible-tower ~]# pip install ansible-tower-cli
Collecting ansible-tower-cli
  Downloading ansible-tower-cli-3.3.9.tar.gz (203 kB)
     |████████████████████████████████| 203 kB 2.8 MB/s
Collecting click<7.0
  Downloading click-6.7-py2.py3-none-any.whl (71 kB)
     |████████████████████████████████| 71 kB 3.8 MB/s
Requirement already satisfied: colorama>=0.3.1 in /usr/local/lib/python3.6/site-packages (from ansible-tower-cli) (0.4.4)
Requirement already satisfied: requests>=2.3.0 in /usr/local/lib/python3.6/site-packages (from ansible-tower-cli) (2.26.0)
Requirement already satisfied: six>=1.7.2 in /usr/lib/python3.6/site-packages (from ansible-tower-cli) (1.11.0)
Requirement already satisfied: PyYAML>=3.10 in /usr/local/lib64/python3.6/site-packages (from ansible-tower-cli) (5.4.1)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.6/site-packages (from requests>=2.3.0->ansible-tower-cli) (1.26.6)
Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.6/site-packages (from requests>=2.3.0->ansible-tower-cli) (2.0.3)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/site-packages (from requests>=2.3.0->ansible-tower-cli) (2021.5.30)
Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3.6/site-packages (from requests>=2.3.0->ansible-tower-cli) (2.5)
Using legacy 'setup.py install' for ansible-tower-cli, since package 'wheel' is not installed.
Installing collected packages: click, ansible-tower-cli
    Running setup.py install for ansible-tower-cli ... done
Successfully installed ansible-tower-cli-3.3.9 click-6.7
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

 

 

2. tower-cli 버전 확인

[root@ansible-tower ~]# tower-cli --version
Tower CLI 3.3.9

 

 

3. tower-cli help page

[root@ansible-tower ~]# tower-cli --help
Usage: tower-cli [OPTIONS] COMMAND [ARGS]...

Options:
  --version  Display tower-cli version.
  --help     Show this message and exit.

Commands:
  config   Read or write tower-cli configuration.
  empty    Empties assets from Tower.
  login    Retrieves and stores an OAuth2 personal auth...
  logout   Removes an OAuth2 personal auth token from...
  receive  Export assets from Tower.
  send     Import assets into Tower.
  version  Display full version information.

Resources:
  activity_stream        Activity on server.
  ad_hoc                 Launch commands based on playbook given at...
  application            Manage OAuth2 applications.
  credential             Manage credentials within Ansible Tower.
  credential_type        Manage credential types within Ansible Tower.
  group                  Manage groups belonging to an inventory.
  host                   Manage hosts belonging to a group within an...
  instance               Check instances within Ansible Tower.
  instance_group         Check instance groups within Ansible Tower.
  inventory              Manage inventory within Ansible Tower.
  inventory_script       Manage inventory scripts within Ansible...
  inventory_source       Manage inventory sources within Ansible...
  inventory_update       Launch or monitor inventory source updates.
  job                    Launch or monitor jobs.
  job_template           Manage job templates.
  label                  Manage labels within Ansible Tower.
  node                   Manage nodes inside of a workflow job...
  notification_template  Manage notification templates within Ansible...
  organization           Manage organizations within Ansible Tower.
  project                Manage projects within Ansible Tower.
  project_update         Launch or monitor project updates.
  role                   Add and remove users/teams from roles.
  schedule               Manage schedules within Ansible Tower.
  setting                Manage settings within Ansible Tower.
  team                   Manage teams within Ansible Tower.
  user                   Manage users within Ansible Tower.
  workflow               Manage workflow job templates.
  workflow_job           Launch or monitor workflow jobs.

 

 

4. tower-cli config 설정

# Tower Host 설정
[root@ansible-tower ~]# tower-cli config host 60.30.157.231
Configuration updated successfully.


# username 설정
[root@ansible-tower ~]# tower-cli config username admin
Configuration updated successfully.

# password 설정
[root@ansible-tower ~]# tower-cli config password <password>
Configuration updated successfully.

# SSL 미 확인 설정
[root@ansible-tower ~]# tower-cli config verify_ssl false
Configuration updated successfully.

 

 

5. tower-cli 사용자 조회

[root@ansible-tower ~]# tower-cli user list
== ======== ======================== ========== ========= ============ =================
id username          email           first_name last_name is_superuser is_system_auditor
== ======== ======================== ========== ========= ============ =================
 1 admin    admin@example.com                                     true             false
 2 hkjeon   hkjeon@etechsystem.co.kr Jeon       Hyukwon           true             false
== ======== ======================== ========== ========= ============ =================

 

 

6. tower-cli 설정값 확인

[root@ansible-tower ~]# tower-cli config

# User options (set with `tower-cli config`; stored in ~/.tower_cli.cfg).
host: 60.30.157.231
username: admin
password: XXXXX
verify_ssl: False

# Defaults.
use_token: False
oauth_token:
description_on: False
certificate:
verbose: False
format: human
insecure: False
color: True

 

 

7. 그 외

그 외 RestAPI 툴을 통해서 Ansible-Tower를 관리할 수도 있다.

Ansible Tower 상태 조회

 

그 외 사용법들

https://docs.ansible.com/ansible-tower/3.2.5/html/towerapi/tower_cli.html

 

10. Introduction to tower-cli — Ansible Tower API Guide v3.2.5

10. Introduction to tower-cli tower-cli is a command line tool for Ansible Tower. It allows Tower commands to be easily run from the UNIX command line. It can also be used as a client library for other python apps, or as a reference for others developing A

docs.ansible.com

 

728x90