Ansible Tower安裝配置全過程(上)

1、準備一臺Linux主機 node

內存要求:4GB以上 python

分區要求:/var必須大於等於20GB linux

其餘略過 git

2、安裝Ansible sql

一、安裝前準備 服務器

(1)首先升級系統 cookie

yum update -y ide

重啓服務器 gitlab

shutdown –r now post

(2)安裝基礎組件

yum -y install gcc glibc-devel make ncurses-devel openssl-devel xmlto perl wget lrzsz zip unzip net-tools libselinux-python

二、安裝

下載完整安裝包,安裝包中包含全部依賴的組件ansible、postgresql等。

下載連接: https://releases.ansible.com/ansible-tower/setup-bundle/

任意目錄直接wget 最新的安裝包

wget https://releases.ansible.com/ansible-tower/setup-bundle/ansible-tower-setup-bundle-latest.el7.tar.gz

解壓

tar zxvf ansible-tower-setup-bundle-latest.el7.tar.gz

修改配置文件

cd ansible-tower-setup-bundle-latest.el7.tar.gz

vi inventory

修改成

[tower]

localhost ansible_connection=local

 

[database]

 

[all:vars]

admin_password='admin'

 

pg_host=''

pg_port=''

 

pg_database='awx'

pg_username='awx'

pg_password='admin'

 

rabbitmq_username=tower

rabbitmq_password='admin'

rabbitmq_cookie=cookiemonster

 

# Isolated Tower nodes automatically generate an RSA key for authentication;

# To disable this behavior, set this value to false

# isolated_key_generation=true

 

注意加粗的是須要添加上去的,其餘不改

 

運行./setup.sh開始安裝,大概須要10分鐘左右,當出現提示時The setup process completed successfully.時表示安裝完成

 

錯誤1:

This machine does not have sufficient RAM to run Ansible Tower

解決:加內存,至少4GB

 

3、配置Ansible

一、訪問192.168.1.76

用戶名:admin

密碼:admin

這都是inventory配置文件中的

 

 

二、導入受權

提示須要受權License

沒有License key是沒法進入系統的,這裏點擊"REQUEST LICENSE",跳轉到Ansible官網申請試用License key

等待審覈經過

4、運行一個測試項目

一、新建playbook

Ansible Tower的playbook默認存在 /var/lib/awx/projects/

playbook將在GitLab上建立,Ansible Tower拉取執行

二、建立HOST登陸憑據

點擊左側菜單Credentials,再點擊右側加號

NAME:192.168.1.165-root

CREDENTIAL TYPE:Machine

用戶名:root

密碼:****

其餘留空,點擊保存

建立完畢

三、在GitLab中添加operation_ansible_playbook.git項目

http://192.168.1.159/******_org/operation/operation_ansible_playbook.git

四、編寫Playbook

文件名:test.yml

內容:

---

- hosts: all

gather_facts: no

 

tasks:

- name: Check the date on the server.

command: date

- name: Check the ip ip on the server.

command: ip add

注意:tasks後必須有一個"-"符號開頭的命令,不然運行會出下邊的錯誤

 

五、在Ansible Tower添加拉取Gitlab項目的憑據

點擊左側菜單Credentials,再點擊右側加號

NAME:gitlab_ansible_palybook

CREDENTIAL TYPE:Source Control

用戶名:lutao

密碼:****

其餘留空,點擊保存

 

六、建立項目

點擊左側菜單Projects,再點擊右側加號

NAME:Pull GitLab

ORGANIZATION:默認

SCM TYPE:Git

SCM URL:http://192.168.1.159/******_org/operation/operation_ansible_playbook.git

SCM BRANCH/TAG/COMMIT:master

SCM CREDENTIAL:gitlab_ansible_palybook

其餘默認

保存後Ansilble Tower會自動運行一次Update,若是要手動運行,點擊列表中的刷新按鈕。當GitLab上yml文件被更新或者新增後須要點擊一下刷新按鈕,不然JOB執行得仍是原來的yml

點擊左側菜單Job,再點擊右側項目名後的火箭圖標

點擊任意項目名能夠查看詳細信息

此時在Ansible Tower服務器的/var/lib/awx/projects/目錄下已經有git拉下來的完整文件結構,其中test.yml是咱們須要的

七、建立主機清單

點擊左側菜單Inventory,再點擊右側加號

NAME:Test Inventory

ORGANIZATION:默認

保存以後點擊上邊的HOST,再點擊加號添加主機

HOST NAME:192.168.1.165

保存以後啓用這個HOST

八、建立任務模板

點擊左側菜單Templates,再點擊右側加號

NAME:Test Job

JOB TYPE:RUN

Inventory:選擇Test Inventory

PROJECT 選擇 Test Project

PALYBOOK 選擇 test.yml

CREDENTIAL 選擇 192.168.1.165-root

其餘默認

九、運行模板

點擊模板名稱右側加號

運行完成後查看運行狀況

點擊右側日誌中change幾行能夠看到詳細信息

 

相關文章
相關標籤/搜索