수색…
매개 변수
매개 변수 | 설명 |
---|---|
ansible_connection | 호스트에 대한 연결 유형. 이것은 잠재적 인 연결 플러그인의 이름 일 수 있습니다. SSH 프로토콜 유형은 smart , ssh 또는 paramiko 입니다. 기본값은 똑똑합니다. 비 SSH 기반 유형은 다음 절에서 설명됩니다. |
ansible_host | 연결할 별칭과 다른 경우 연결할 호스트의 이름입니다. |
ansible_port | ssh 포트 번호 (22가 아닌 경우) |
ansible_user | 사용할 기본 ssh 사용자 이름입니다. |
ansible_ssh_pass | 사용할 ssh 암호 (이것은 안전하지 않으며 --ask-pass 또는 SSH 키 사용을 강력히 권장합니다) |
ansible_ssh_private_key_file | ssh가 사용하는 개인 키 파일. 여러 키를 사용하고 SSH 에이전트를 사용하지 않으려는 경우 유용합니다. |
ansible_ssh_common_args | 이 설정은 sftp , scp 및 ssh 의 기본 명령 줄에 항상 추가됩니다. 특정 호스트 (또는 그룹)에 대해 ProxyCommand 를 구성하는 ProxyCommand 유용합니다. |
ansible_sftp_extra_args | 이 설정은 항상 기본 sftp 명령 행에 추가됩니다. |
ansible_scp_extra_args | 이 설정은 항상 기본 scp 명령 줄에 추가됩니다. |
ansible_ssh_extra_args | 이 설정은 항상 기본 ssh 명령 줄에 추가됩니다. |
ansible_ssh_pipelining | SSH 파이프 라이닝을 사용할지 여부를 결정합니다. 이것은 ansible.cfg 의 pipelining 설정을 무시할 수 있습니다. |
안심할 수있다. | ansible_sudo 또는 ansible_su 와 동등한 권한 승격 권한을 부여 할 수 있습니다. |
불가능한 _ 방법 | 권한 에스컬레이션 방법을 설정할 수 있습니다. |
~ 할 수있다. | ansible_sudo_user 또는 ansible_su_user 와 동등한 권한 승격을 통해 사용자를 설정할 수 있습니다. |
가능하다. | ansible_sudo_pass 또는 ansible_su_pass 와 동일하게 권한 에스컬레이션 암호를 설정할 수 있습니다 |
ansible_shell_type | 대상 시스템의 쉘 유형. ansible_shell_executable 을 Bourne (sh)이 아닌 호환 쉘로 설정하지 않는 한이 설정을 사용하지 마십시오. 기본적으로 명령은 sh 스타일 구문을 사용하여 형식이 지정됩니다. 이것을 csh 나 fish 설정하면 대상 시스템에서 실행 된 명령이 대신 해당 셸의 구문을 따르게됩니다. |
ansible_python_interpreter | 대상 호스트 파이썬 경로. 이것은 하나 이상의 파이썬이 있거나 / BSD와 같은 / usr / bin / python 에 없거나 / usr / bin / python 이 2.X 시리즈 Python이 아닌 시스템에 유용합니다. 우리는 / usr / bin / env 메커니즘을 사용하지 않습니다. 원격 사용자의 경로를 올바르게 설정해야하며 python 실행 파일의 이름이 python 인 것으로 가정합니다. 여기서 실행 파일의 이름은 python2.6 과 같을 수 있습니다. |
불가능한 _ 해석기 | 루비 나 펄과 같은 ansible_python_interpreter 작동하며, ansible_python_interpreter 와 같이 작동합니다. 이것은 해당 호스트에서 실행될 모듈의 새 행을 대체합니다. |
ansible_shell_executable | 이것은 잠재적 인 컨트롤러가 대상 컴퓨터에서 사용할 쉘을 설정하며, 기본적으로 / bin / sh 인 ansible.cfg 에서 executable 을 재정의합니다. / bin / sh 를 사용할 수 없다면 (예 : / bin / sh 가 대상 컴퓨터에 설치되어 있지 않거나 sudo에서 실행할 수없는 경우에만) 변경해야합니다. 버전 2.1의 새로운 기능. |
사용자 이름과 비밀번호가있는 인벤토리
인벤토리는 인프라의 모든 시스템을 추적 할 수있는 확실한 방법입니다. 다음은 단일 시스템을 포함하는 간단한 인벤토리 파일과 Ansible의 로그인 자격 증명입니다.
[targethost]
192.168.1.1 ansible_user=mrtuovinen ansible_ssh_pass=PassW0rd
사용자 정의 개인 키가있는 인벤토리
[targethost]
192.168.1.1 ansible_user=mrtuovinen ssh_private_key_file=~/.ssh/custom_key
사용자 정의 SSH 포트가있는 인벤토리
[targethost]
192.168.1.1 ansible_user=mrtuovinen ansible_port=2222
고정 인벤토리를 책임있는 플레이 북에 전달합니다.
ansible-playbook -i path/to/static-inventory-file -l myhost myplaybook.yml
다이내믹 인벤토리를 안전한 플레이 북에 전달하십시오.
ansible-playbook -i path/to/dynamic-inventory-script.py -l myhost myplaybook.yml
자세한 내용은 동적 인벤토리 를 참조하십시오.
인벤토리, 그룹 변수 및 사용자
프로젝트 구조 (가능한 모범 사례).
project/
group_vars/
development
inventory.development
playbook.yaml
그것은 모두 inventory.development로 시작합니다.
[development]
dev.fakename.io
[development:vars]
ansible_host: 192.168.0.1
ansible_user: dev
ansible_pass: pass
ansible_port: 2232
[api:children]
development
group_vars에 연결할 수 있습니다. 해당 환경에 '특정'데이터 보관 ...
---
app_name: NewApp_Dev
app_url: https://dev.fakename.io
app_key: f2390f23f01233f23f
인벤토리 파일에 대해 다음과 같은 재생 목록을 실행할 수있게합니다.
---
- name: Install api.
hosts: api
gather_facts: true
sudo: true
tags:
- api
roles:
- { role: api, tags: ["api"] }
다음 런 라인과 함께 :
ansible-playbook playbook.yaml -i inventory.development
호스트 파일
호스트 파일은 Anisble 게임 플레이 북 연결을 저장하는 데 사용됩니다. 연결 매개 변수를 정의하는 옵션이 있습니다.
ansible_host
는 호스트 이름 또는 IP 주소입니다.
ansible_port
는 컴퓨터가 SSH에 사용하는 포트입니다.
ansible_user
는 다음과 같이 연결할 원격 사용자입니다.
SSH에 암호를 사용하는 경우 ansible_ssh_pass
호스트와 관련된 여러 개의 키를 사용해야하는 경우 ansible_ssh_private_key_file
가장 많이 사용되는 옵션입니다. 자세한 내용은 Ansible 공식 문서 에서 확인할 수 있습니다.
다음은 hosts
파일의 예입니다.
# Consolidation of all groups
[hosts:children]
web-servers
offsite
onsite
backup-servers
[web-servers]
server1 ansible_host=192.168.0.1 ansible_port=1600
server2 ansible_host=192.168.0.2 ansible_port=1800
[offsite]
server3 ansible_host=10.160.40.1 ansible_port=22 ansible_user=root
server4 ansible_host=10.160.40.2 ansible_port=4300 ansible_user=root
# You can make groups of groups
[offsite:children]
backup-servers
[onsite]
server5 ansible_host=10.150.70.1 ansible_ssh_pass=password
[backup-servers]
server6 ansible_host=10.160.40.3 ansible_port=77
Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow