ansible (30) 썸네일형 리스트형 [Ansible] VMware ESXi 사용하기 모듈설치 pyvmomi yum install python2-pyvmomi 호스트 등록 ESXi ssh public key 교환은 여기 참조 [esxi] [esxi:vars] ansible_python_interpreter=/usr/bin/python3 ansible_connection=ssh ansible_user=root ansible_ssh_private_key_file=~/.ssh/id_rsa ping 테스트 ansible esxi -m ping | SUCCESS => { "changed": false, "ping": "pong" } Windows Ansible | [Playbook] 역할 및 기능 설치(win_feature) playbook state : present(설치) | absent(제거) include_sub_feature : yes | no 하위 항목 모두 설치 --- - hosts: all gather_facts: no ignore_unreachable: yes tasks: # IIS, VSS 설치 - name: Install IIS (Web-Server only) win_feature: name: - Web-Server - Windows-Server-Backup state: present include_sub_features: yes register: win_feature # 설치 후 필요한 경우 재부팅 - name: Reboot if installing Web-Server feature requires it.. Windows Ansible | [Playbook] shutdown, reboot, service winrm 설치는 여기 참조 윈도우 전원 shutdown --- - hosts: all gather_facts: no ignore_unreachable: yes tasks: - name: Run an executable and send data to the stdin for the executable win_command: powershell.exe Stop-Computer -Force 윈도우 전원 reboot --- - hosts: all gather_facts: no ignore_unreachable: yes tasks: - name: Reboot the machine with all defaults win_reboot: 윈도우 서비스 모듈 start_mode : auto | delayed | dis.. 9. ansible | windows winrm을 이용한 ansible 사용 1. ssh를 사용하는 리눅스 대신 윈도우는 winrm 모듈의 http를 통하여 powershell 플러그인과 통신을 통하여 ansible을 이용할 수 있음. 2. 테스트 환경 : windows server 2012 3. windows server 2012는 기본적으로 winrm 이 동작중 PS C:\Users\Administrator> Get-Service -Name winrm Status Name DisplayName ------ ---- ----------- Running winrm Windows Remote Management (WS-Manag... 4. winrm listener 정보 확인 - http default port 5985을 사용 PS C:\Users\Administrator> win.. 8.5 ansible | [playbook] docker 설치 # docker-ce-20.10.5 --- - hosts: all become: yes tasks: - name: "yum install packages" yum: name: "{{ item }}" state: installed loop: - epel-release - yum-utils - git - name: "docker repo add" command: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo - name: "docker install" yum: name: "{{ item }}" state: installed loop: - docker-ce-20.10.5 - python3 - python.. 8.4 ansible | [playbook] nodejs, npm 설치 ## nodejs 14.15.4, npm 6.14.10 --- - name: "NPM, NODEJS INSTALL" become: true hosts : all gather_facts: no tasks: - name: "install wget" yum: name: wget state: installed - name: "repo download" get_url: url: https://rpm.nodesource.com/setup_lts.x dest: /tmp/node_setup.sh - name: "repo install" shell: /bin/bash /tmp/node_setup.sh - name: "install nodejs" yum: name: "{{ item }}" state: installed l.. 8.3 ansible | [playbook] centos6 yum repository 변경 centos6의 공식 repository가 만료되어 아래와 같이 주소 변경. --- - name: "Modify CentOS6 Base Repo" hosts: all become: true tasks: - name: "Modify CentOS6 Base Repo" replace: path: /etc/yum.repos.d/CentOS-Base.repo regexp: "{{ item.origin }}" replace: "{{ item.replace }}" with_items: - { origin: "mirrorlist=http://mirrorlist.centos.org", replace: "#mirrorlist=http://mirrorlist.centos.org" } - { origin: "#baseurl=.. 8.2 ansible | [playbook] Linux service 상태 변경 --- - name: "Change Service State " hosts: all become: true tasks: - name: "Change Service State " service: name: "{{ service_name }}" # state : reloaded|restarted|started|stopped state: "{{ service_state }}" # enabled : yes|no enabled: "{{ service_enable }}" # 조건 : centos 6 or 7 인 경우만 when: - ansible_facts['distribution'] == "CentOS" - ( ansible_facts['distribution_major_version'] == "6" or ans.. 8.1 ansible | [playbook] Linux user 추가 linux ssh를 통해 user를 생성 하고 sudo 권한을 추가 --- - name: "user add" hosts: all # sudo 권한 획득 become: true tasks: - name: "user add" user: name: "{{ add_user_name }}" password: "{{ upassword | password_hash('sha512') }}" shell: "/bin/bash" - name: "Add user to sudoers" lineinfile: dest: /etc/sudoers regexp: "{{ add_user_name }} ALL" line: "{{ add_user_name }} ALL=(ALL) NOPASSWD: ALL" state: present #vars.. 7. ansible inventory 설정 과 playbook 실행 Inventory 설정 linux 1개의 호스트 (한줄 쓰기) # linux ssh testansible_host={linux ip} ansible_user={linux user} ansible_port={ssh port} ansible_connection=ssh ansible_ssh_pass="{password}" windows 그룹지정하기 # plo 그룹 [plo] plo1 ansible_host= ansible_password="" plo2 ansible_host= ansible_password="" # plo 그룹 변수 [plo:vars] ansible_user=administrator ansible_connection=winrm ansible_winrm_server_cert_validation=.. 이전 1 2 3 다음