ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • ansible inventory .yaml 작성법
    OS/ansible 2022. 4. 19. 10:59

    ansible 디폴트 인벤토리 파일 지정 - 같은경로의 study.yaml, common.yaml 파일 참조
    sudo vi /etc/ansible/ansible.cfg
    [defaults]
    inventory =./study.yaml, common.yaml
    :wq!

    ===============================================================


    yaml 파일 작성 방법(들여쓰기 중요)
    all:
      hosts:    - 미지정그룹
        1.1.1.1
      children:    - 지정그룹
        test1:    - 그룹명(test1)
          hosts:    - test1그룹의 호스트
            jumper1:    - 호스트중 하나의 별칭(jumper1)
              ansible_port: 22222      - jumper1의 ssh접속포트(기본포트22면 불필요)
              ansible_host: 192.168.72.132    - jumper1의 주소
            jumper2:
              ansible_port: 22222
              ansible_host: 192.168.72.133
      vars:    - 모든서버에서사용할수있는변수
        global_vars: "server_name"

    또는

    all:
      children:
        dbservers:    - 그룹명
          hosts:
            dbservers-host:    - 그룹명-호스트
          vars:    - dbservers 그룹에서 사용할 변수
            db_id: "helen"
            db_passwd: "helen1!"


    'OS > ansible' 카테고리의 다른 글

    ansible-playbook 02 tar  (0) 2022.04.19
    ansible-playbook 01 apache(httpd), nginx 설치  (0) 2022.04.19
    ansible inventory .ini파일 작성법  (0) 2022.04.19
    ansible 설치 및 기본 옵션  (1) 2022.04.19

    댓글

Designed by Tistory.