Câu hỏi thường gặp
Chỉ hiển thị nội dung serverplaybook
cấu hình-cm $servername
Làm cách nào để thêm vai trò?
configure-cm --role $role $servername
Xóa một vai trò?
configure-cm --delete --role $role $server --message "$reason"
Thêm một kế hoạch chi tiết?
cấu hình-cm -b $blueprint $servername
Xóa bản thiết kế?
configure-cm --delete --blueprint $blueprint $server
Hiển thị tài liệu về mô-đun Ansible
ansible-doc $modulename
Thêm biến playbook?
configure-cm --var múi giờ=UTC degtlun7904
Thêm biến playbook?
configure-cm --var '[{ntp_servers. [145. 228. 39. 44,145. 228. 145. 3]}]' degtlun7904
Thêm biến playbook?
configure-cm --var @/tmp/yaml_file degtlun7904
Làm cách nào để khắc phục các thay đổi trong playbook không được cam kết?
configure-cm --commit-only $servername
Thêm một biến có vai trò
configure-cm --role postfix --var relayhost=cmail. xuyên mạng. net $srvname
thêm sudoer
cấu hình-cm $servername --sudoers TOMCAT_sudoers
Thêm Tác vụ từ tệp YAML - Giới hạn người dùng
$ cat /tmp/ansible_task.yml
---
- name: degtlun7904.yml | /etc/security/limits.conf | Set user limits nofile
pam_limits:
domain: '*'
limit_type: "-"
limit_item: "nofile"
value: 8192
tags: limits
$ configure-cm degtlun7904 --task /tmp/ansible_task.yml
$ run-cm degtlun7904 -t limits
thêm một gói
# Tabcompletion for packages from csrepo
$ configure-cm $servername --pkg dba-tomcat-7047-core
$ run-cm $servername -t pkgs
Thêm một nhóm mạng
# Tabcompletion
$ configure-cm $srvname --netgroup ng_dba_ext
$ run-cm $srvname -t netgroups
Công cụ trên degtlun1235
chạy cm
Chạy playbook Ansible
cấu hình-cm
Định cấu hình playbook máy chủ
phân phối_jumpserver. sh
Cập nhật vai trò máy chủ nhảy trên tất cả các máy chủ nhảy
vai trò
asmlib
apache
ngao
CỐT LÕI
đồng bộ hóa
csrepo
cốc
người đóng tàu
bổ sung_repo
nfs_mount
nfs_server
hậu tố
sdk_repo
symantec
symantec_hids
bản thiết kế
apache
check_mk
đầu bếp
cs_nrpe_client
ggaddm
hana
mysql
ORA
postgres
nhựa cây
SYB
WEB
CORE - Các thẻ biến quan trọng
dns_search
dns_search. như. lekkerland. com otg. tập đoàn. máy chủ int. hệ thống arvato. de betelsmann. de
dns
dns_servers
dns_servers.
- 172. 25. 192. 31
- 172. 25. 192. 20
- 172. 25. 168. 12
dns
dns_no_shuffle
dns_no_shuffle. ĐÚNG VẬY
dns
kernel_ip_forwarding
kernel_ip_forwarding. 1
chuyển tiếp ip
pe_numbers
pe_numbers.
- số. PE00001111
lý do. FTP
ngày kết thúc. 20170616
motd
sshd_only_dialogip
sshd_only_dialogip. ĐÚNG VẬY
sshd
Múi giờ
Múi giờ. UTC
Múi giờ
a
Một thẻ đã tồn tại với tên chi nhánh được cung cấp. Nhiều lệnh Git chấp nhận cả tên thẻ và tên nhánh, vì vậy việc tạo nhánh này có thể gây ra hành vi không mong muốn. Bạn có chắc chắn muốn tạo nhánh này không?
thực thi với phiên bản python từ xa cụ thể, python từ xa, viết lại biến mặc định, viết lại biến, ghi đè biến
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
chỉ thực thi ansible cho một máy chủ, một máy chủ, một máy chủ xóa, mức độ chi tiết
pip3 install ansible
# for python2 - default installation
pip install ansible
0tập tin đơn giản để tạo một thư mục
pip3 install ansible
# for python2 - default installation
pip install ansible
1thực thi ansible cục bộ, thực thi cục bộ
pip3 install ansible
# for python2 - default installation
pip install ansible
2thực thi ansible-playbook với tham số bên ngoài, tập lệnh bash ansible-playbook với tham số, biến phụ, biến ngoài, env var
pip3 install ansible
# for python2 - default installation
pip install ansible
3pip3 install ansible
# for python2 - default installation
pip install ansible
4với đường dẫn đến tệp cho các tham số bên ngoài, các biến bổ sung từ tệp bên ngoài
pip3 install ansible
# for python2 - default installation
pip install ansible
5biến bên ngoài nội tuyến
pip3 install ansible
# for python2 - default installation
pip install ansible
6kiểm tra xem nó có hoạt động không, lệnh ad-hoc
pip3 install ansible
# for python2 - default installation
pip install ansible
7pip3 install ansible
# for python2 - default installation
pip install ansible
8ví dụ vòng lặp
pip3 install ansible
# for python2 - default installation
pip install ansible
9thực hiện lặp lại
# Tabcompletion for packages from csrepo
$ configure-cm $servername --pkg dba-tomcat-7047-core
$ run-cm $servername -t pkgs
40bắt đầu với nhiệm vụ, thực hiện từ nhiệm vụ, bắt đầu với nhiệm vụ, bỏ qua các nhiệm vụ trước đó
# Tabcompletion for packages from csrepo
$ configure-cm $servername --pkg dba-tomcat-7047-core
$ run-cm $servername -t pkgs
41thay thế các biến bên trong tệp thành tệp chuyên dụng, di chuyển vars sang tệp riêng
- trước
# Tabcompletion for packages from csrepo
$ configure-cm $servername --pkg dba-tomcat-7047-core
$ run-cm $servername -t pkgs
42- sau [khối 'vars' trống] filepath
# Tabcompletion for packages from csrepo
$ configure-cm $servername --pkg dba-tomcat-7047-core
$ run-cm $servername -t pkgs
43hoặc groupvars
# Tabcompletion for packages from csrepo
$ configure-cm $servername --pkg dba-tomcat-7047-core
$ run-cm $servername -t pkgs
44mã số
# Tabcompletion for packages from csrepo
$ configure-cm $servername --pkg dba-tomcat-7047-core
$ run-cm $servername -t pkgs
45di chuyển mã vào tệp riêng biệt, tác vụ vào tệp
cắt mã từ tệp gốc và dán vào tệp riêng [có căn chỉnh phù hợp. ], viết thay vì mã
# Tabcompletion for packages from csrepo
$ configure-cm $servername --pkg dba-tomcat-7047-core
$ run-cm $servername -t pkgs
46tập tin thích hợp nên được tạo ra
# Tabcompletion for packages from csrepo
$ configure-cm $servername --pkg dba-tomcat-7047-core
$ run-cm $servername -t pkgs
47bỏ qua/kích hoạt một số tác vụ với ghi nhãn, gắn thẻ
# Tabcompletion for packages from csrepo
$ configure-cm $servername --pkg dba-tomcat-7047-core
$ run-cm $servername -t pkgs
48đa thẻ, nhiều thẻ
# Tabcompletion for packages from csrepo
$ configure-cm $servername --pkg dba-tomcat-7047-core
$ run-cm $servername -t pkgs
49# Tabcompletion
$ configure-cm $srvname --netgroup ng_dba_ext
$ run-cm $srvname -t netgroups
40gỡ lỗicẩm nang sửa lỗi
# Tabcompletion
$ configure-cm $srvname --netgroup ng_dba_ext
$ run-cm $srvname -t netgroups
41biến in
# Tabcompletion
$ configure-cm $srvname --netgroup ng_dba_ext
$ run-cm $srvname -t netgroups
42thay đổi biến
# Tabcompletion
$ configure-cm $srvname --netgroup ng_dba_ext
$ run-cm $srvname -t netgroups
43đặt biến
# Tabcompletion
$ configure-cm $srvname --netgroup ng_dba_ext
$ run-cm $srvname -t netgroups
44vỏ == ansible. được xây dựng trong. vỏ bọc
quản lý chơi
# Tabcompletion
$ configure-cm $srvname --netgroup ng_dba_ext
$ run-cm $srvname -t netgroups
45# Tabcompletion
$ configure-cm $srvname --netgroup ng_dba_ext
$ run-cm $srvname -t netgroups
46lệnh gỡ lỗi
# Tabcompletion
$ configure-cm $srvname --netgroup ng_dba_ext
$ run-cm $srvname -t netgroups
47# Tabcompletion
$ configure-cm $srvname --netgroup ng_dba_ext
$ run-cm $srvname -t netgroups
48biến env bashrc
# Tabcompletion
$ configure-cm $srvname --netgroup ng_dba_ext
$ run-cm $srvname -t netgroups
49sao chép tập tin rsync
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
40ec2 quản lý luồng không khí ec2
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
41mô-đun gỡ lỗi
tệp đối số [ args. json ]
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
42tập tin thực thi
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
43đặt điểm dừng
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
44chạy cho đến khi điểm dừng
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
45gỡ lỗi mô-đun nội tuyến, thực thi mô-đun nội tuyến, kiểm tra mô-đun adhoc
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
46nhiệm vụ in tất cả các biến
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
47ansible-console
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
48thiết bị xuất chuẩn in ansible
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
49xử lý lỗi, thử bắtngừng thực hiện các bước [của playbook] khi có ít nhất một máy chủ báo lỗi
pip3 install ansible
# for python2 - default installation
pip install ansible
40không ném lỗi cho một nhiệm vụ nhất định
pip3 install ansible
# for python2 - default installation
pip install ansible
41thất bại khi, thất bại theo điều kiện, phân tích tệp nhật ký để tìm lỗi
pip3 install ansible
# for python2 - default installation
pip install ansible
42mẫu, tạo khuôn mẫu Jinja2, đường ống, lọc ansiblegiá trị mặc định
pip3 install ansible
# for python2 - default installation
pip install ansible
43thoát ký tự đặc biệt
pip3 install ansible
# for python2 - default installation
pip install ansible
44hoạt động với danh sách
pip3 install ansible
# for python2 - default installation
pip install ansible
45tên tệp từ đường dẫn [trả về 'script. ch']
pip3 install ansible
# for python2 - default installation
pip install ansible
46sao chép tập tin và đổi tên nó, hậu tố thay thế đường ống
pip3 install ansible
# for python2 - default installation
pip install ansible
47điều kiện jinja
pip3 install ansible
# for python2 - default installation
pip install ansible
48sao chép sao chép ngược từ máy đích
pip3 install ansible
# for python2 - default installation
pip install ansible
49chỉ thị cho Jinja
để cải thiện thụt đầu dòng trên toàn cầu trong tệp, hãy thêm một trong những dòng tiếp theo vào đầu
pip3 install ansible
# for python2 - default installation
pip install ansible
40chỉ để cải thiện thụt đầu dòng cho khối
pip3 install ansible
# for python2 - default installation
pip install ansible
41ví dụ điều kiện
pip3 install ansible
# for python2 - default installation
pip install ansible
42chỉ thị cho vòng lặp, vòng lặp cuối cùng, vòng lặp cuối cùng
pip3 install ansible
# for python2 - default installation
pip install ansible
43trốn thoát
chỉ là một biểu tượng
pip3 install ansible
# for python2 - default installation
pip install ansible
44đoạn mã lớn hơn
pip3 install ansible
# for python2 - default installation
pip install ansible
45mẫu với tempfile
pip3 install ansible
# for python2 - default installation
pip install ansible
46- tạo mô-đun tùy chỉnh
cài đặt cho các mô-đun
cũng cần 'thông báo' ansible về mô-đun đưa ra một trong các tùy chọn tiếp theo
- thêm thư mục của bạn với mô-đun vào biến môi trường ANSIBLE_LIBRARY
- cập nhật $HOME/. ansible. cfg
pip3 install ansible # for python2 - default installation pip install ansible
47
tài liệu mô-đun
pip3 install ansible
# for python2 - default installation
pip install ansible
48mô-đun tối thiểu
pip3 install ansible
# for python2 - default installation
pip install ansible
49bổ sungví dụ về plugin
pip3 install ansible
# for python2 - default installation
pip install ansible
40mã python cho plugin
pip3 install ansible
# for python2 - default installation
pip install ansible
41chấp hành
pip3 install ansible
# for python2 - default installation
pip install ansible
42tra cứu
pip3 install ansible
# for python2 - default installation
pip install ansible
43thay thế giá trị từ tệp có định dạng đặc biệt
pip3 install ansible
# for python2 - default installation
pip install ansible
44biến tra cứu
pip3 install ansible
# for python2 - default installation
pip install ansible
45pip3 install ansible
# for python2 - default installation
pip install ansible
46tập tin kiểm kêtệp kiểm kê, tệp kiểm kê có biến, quy tắc
pip3 install ansible
# for python2 - default installation
pip install ansible
47hàng tồn kho động
hàng tồn kho trăn. py [có phần mở rộng 'py'] thay vì txt
pip3 install ansible
# for python2 - default installation
pip install ansible
48logic tiếp theo cũng nên có mặt
pip3 install ansible
# for python2 - default installation
pip install ansible
49kịch bản chuẩn bị
tệp kiểm kê với các biến [ python Jinja tạo khuôn mẫu]
pip3 install ansible
# for python2 - default installation
pip install ansible
40cách sử dụng sách giải trí
pip3 install ansible
# for python2 - default installation
pip install ansible
41thực hiện với các ví dụ về khoảng không quảng cáo
cho một máy chủ cụ thể không có tệp kiểm kê
pip3 install ansible
# for python2 - default installation
pip install ansible
42với tập tin hàng tồn kho
pip3 install ansible
# for python2 - default installation
pip install ansible
43vấn đề với playbook thực thi chỉ dành cho máy chủ cục bộ, thực thi cục bộ
pip3 install ansible
# for python2 - default installation
pip install ansible
44dung dịch
pip3 install ansible
# for python2 - default installation
pip install ansible
45giải pháp2
pip3 install ansible
# for python2 - default installation
pip install ansible
46chiến lượcpip3 install ansible
# for python2 - default installation
pip install ansible
47- tuyến tính [mặc định] sau mỗi bước chờ tất cả các máy chủ
- miễn phí độc lập cho tất cả các máy chủ - ai đó có thể hoàn tất cài đặt sớm hơn đáng kể so với những người khác
tham số bổ sung - chỉ định số lượng máy chủ sẽ được thực thi tại thời điểm đó [chỉ dành cho chiến lược mặc định]
pip3 install ansible
# for python2 - default installation
pip install ansible
48pip3 install ansible
# for python2 - default installation
pip install ansible
49--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
0giá trị mặc định "nối tiếp" vào cấu hình ansible. cfg
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
1thực thi không đồng bộ, nhiệm vụ hiện tại, thực thi lệnhkhông phải tất cả các mô-đun đều hỗ trợ thao tác này thực thi lệnh ở chế độ không đồng bộ [với ước tính sơ bộ là 120 giây], với kết quả thăm dò mặc định của lệnh - 10 [giây]
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
2thực thi lệnh ở chế độ không đồng bộ [với ước tính sơ bộ 120 giây], với kết quả thăm dò của lệnh - 60 [giây]
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
3thực hiện lệnh và quên, không chờ thực hiện
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
4thực thi lệnh ở chế độ không đồng bộ, ghi kết quả kiểm tra kết quả ở cuối tệp
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
5vai tròinit project ansible-galaxy, tạo vai trò mới, vai trò init
thực thi mã vào thư mục dự án của bạn '. /vai trò'
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
6kết quả
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
7chèn vào mã
--extra-vars "remote_folder=$REMOTE_FOLDER ansible_python_interpreter=/usr/bin/python"
8tất cả các thư mục của dự án đã tạo sẽ được áp dụng cho dự án của bạn [tác vụ, vars, mặc định] trong trường hợp tạo thủ công - chỉ có thể tạo các thư mục cần thiết