분류 전체보기 (313) 썸네일형 리스트형 1.2 ansible | [test][playbook] 파일 복사와 삭제 1. 파일 복사 playbook [root@ANSIBLE ansible]# cat copy_file.yml --- - name: "copy file" hosts: test02 become: true tasks: - name: "backup file" # command로 파일 선 백업 command: mv /hosts /hosts.bak - name: "copy files" # copy 모듈로 local -> remote로 파일 복사 copy: src: /etc/hosts dest: / 2. 파일 삭제 playbook [root@ANSIBLE ansible]# cat rm_file.yml --- - name: "delete file" hosts: test1 become: true tasks: - name:.. 1.1 ansible | [test][playbook] 사용자 계정 추가 1. playbook [root@ANSIBLE ansible]# cat add_user.yml --- - name: "user add" hosts: test01 become: true # 권한 상승 tasks: - name: "user add" # user 모듈을 사용하여 사용자 추가 user: name: "{{ add_user_name }}" password: "{{ upassword | password_hash('sha512') }}" shell: "/bin/bash" - name: "Add user to sudoers" # lineinfile 모듈을 사용하여 권한상승 설정 추가 lineinfile: dest: /etc/sudoers regexp: "{{ add_user_name }} ALL" lin.. 0. ansible 설치 1. 설치 [root@ANSIBLE ~]# yum install epel-release [root@ANSIBLE ~]# yum install ansible [root@ANSIBLE ~]# rpm -qa | grep ansible ansible-2.9.16-1.el7.noarch 2. host 등록 ## 기본 경로 [root@ANSIBLE ansible]# pwd /etc/ansible ## inventory 파일 (target host 정의) [root@OANSIBLE ansible]# cat hosts ... [test] test02 ansible_host={host ip} ansible_user={host ssh user} ansible_port={host ssh port} ansible_connec.. 이전 1 ··· 29 30 31 32 다음