본문 바로가기

반응형

리눅스

C276x260 ansible-playbook 명령어 ansible-playbook 명령어 ansible-playbook 명령어는 Ansible로 작성된 플레이북을 실행하는데 사용되는 명령어입니다. 플레이북은 시스템 설정, 소프트웨어 설치, 배포, 설정 등을 자동화하기 위한 Ansible의 설정 파일입니다. ansible ad-hoc 명령어(shell module) ansible 명령어의 주요 옵션과 사용 방법 1. 기본 구문 ansible [options] [-m ] 2. 주요 옵션 : 대상 호스트 또는 그룹을 지정합니다. 와일드카드(*), 호스트명, 그룹명, 그룹 패턴 등으로 지정할 수 있습니다. -m, --module-name: 실행할 모듈을 지정합니다. -a, --args: 모듈에 전달할 인수를 지정합니다. -i, --inventory: 사용할 인벤.. 더보기
C276x260 [Ansible] ansible-playbook apache(httpd) install ansible-playbook apache(httpd) install os-pkg-apache.yaml edit vim os-pkg-apache.yaml --- ### ansible -i ~/ansible-spec/inventory kube-node1 -m gather_facts ### ansible-doc yum ### ansible-doc apt - hosts: all gather_facts: yes tasks: - name: install apache on centos yum: name: httpd state: present when: ansible_facts['distribution'] == "CentOS" and ansible_facts['lsb']['major_release'] | int >=.. 더보기
C276x260 앤서블 플레이북 키워드 앤서블 플레이북 키워드(Playbook Keywords)Ansible 플레이북(Playbook)은 Ansible에서 자동화 작업을 수행하기 위한 주요 구성 파일입니다. 각 플레이북은 여러 작업(task)들을 정의하며 시스템이나 네트워크 장비 등의 상태를 원하는 방향으로 변경하는 데 사용됩니다.주요 Ansible 플레이북 키워드name설명 : 작업 또는 플레이의 이름을 정의합니다. 사람이 이해하기 쉽게 설명하는 부분입니다위치 : 플레이북 또는 개별 작업에서 사용됩니다.name: Install NGINXhosts설명 : 이 플레이를 실행할 호스트 그룹을 지정합니다.위치 : 플레이 단위에서 사용됩니다.hosts: webserverstasks설명 : 실행할 작업 목록을 정의하는 곳입니다. 각 작업은 모듈 호출 .. 더보기
C276x260 [Ansible] facts 모듈(facts module) Ansible facts 모듈(facts module) : 원격 호스트에 대한 정보 수집 kube-node1에 대한 정보 수집 ansible -i ~/ansible-spec/inventory kube-node1 -m gather_facts $ ansible -i ~/ansible-spec/inventory -m setup kube-node1 kube-node1 | SUCCESS => { "ansible_facts": { "ansible_all_ipv4_addresses": [ "172.17.0.1", "169.254.25.10", "10.233.0.1", "10.233.0.3", "10.233.51.47", "192.168.0.61", "10.233.73.64" ], "ansible_all_ipv6_ad.. 더보기
C276x260 [Ansible] ansible-config 명령 ansible-config 명령 ansible-config -h $ ansible-config -h usage: ansible-config [-h] [--version] [-v] {list,dump,view,init} ... View ansible configuration. positional arguments: {list,dump,view,init} list Print all config options dump Dump configuration view View configuration file init Create initial configuration optional arguments: --version show program's version number, config file location, .. 더보기
C276x260 [Ansible] ansible-doc 명령 ansible-doc 명령 : plugin documentation tool ansible-doc 사용법 ansible-doc -h $ ansible-doc -h usage: ansible-doc [-h] [--version] [-v] [-M MODULE_PATH] [--playbook-dir BASEDIR] [-t {become,cache,callback,cliconf,connection,httpapi,inventory,lookup,netconf,shell,vars,module,strategy,role,keyword}] [-j] [-r ROLES_PATH] [-e ENTRY_POINT | -s | -F | -l | --metadata-dump] [plugin [plugin ...]] plugin doc.. 더보기
C276x260 Ansible 인벤토리를 YAML 파일로 설정하는 방법 Ansible 인벤토리를 YAML 파일로 설정하는 방법 YAML 파일을 사용하여 호스트 그룹 및 호스트에 대한 정보를 정의할 수 있습니다. 기본적인 YAML 형식의 Ansible 인벤토리 예제 Ansible 인벤토리 파일 편집 vim hosts.yml --- all: # all 그룹 정의 hosts: webserver: ansible_host: 192.168.1.10 ansible_user: ubuntu ansible_ssh_private_key_file: /path/to/private_key.pem database: ansible_host: 192.168.1.11 ansible_user: centos ansible_password: your_password webservers: # webservers .. 더보기
C276x260 Ansible 구성 설정(Configuration Settings) 파일의 우선 순위에 대한 설명 Ansible 구성 설정(Configuration Settings) 파일의 우선 순위에 대한 설명 구성 설정 파일(ansible.cfg)의 우선 순위 1. 환경 변수 (Environment Variables) Ansible은 ANSIBLE_CONFIG 환경 변수를 통해 구성 파일의 경로를 지정할 수 있습니다. 이 환경 변수가 설정되어 있으면 해당 경로의 구성 파일이 사용됩니다. export ANSIBLE_CONFIG=/path/to/your/ansible.cfg 2. 커맨드 라인 인수 (Command Line Arguments) ansible-playbook이나 ansible 명령을 실행할 때 -i나 -e와 같은 인수를 사용하여 구성을 지정할 수 있습니다. 이는 명령이 실행되는 동안 구성을 임시로 설정하.. 더보기

728x90
반응형