[Devops] Ansible 실습

2025. 3. 13. 12:41·Linux

1. Ansible을 사용한 서버 구축 자동화

ansible을 사용하여 클라우드 서버 A로 부터 B ,C의 인스턴스에 서버를 자동으로 구축 할 수 있도록

코드 작성

---
- name:
  hosts: all
  tasks:
    - name: Install httpd php*
      dnf:
        name: 
          - httpd
          - php
        state: latest
          
    - name: start httpd
      service:
        name: httpd
        state: started
    - name: enable php
      service:
        name: httpd
        enabled: yes
  
    - name: open firewall
      firewalld:
        service: "{{ item }}"
        permanent: yes
        state: enabled
        immediate: yes
      with_items:
        - http
        - ssh
        - telnet 
        - ftp
    - name: wget wordpress
      shell: wget https://ko.wordpress.org/latest-ko_KR.zip

    - name: unzip wordpress
      shell: unzip latest-ko_KR.zip

    - name: move wordpress
      shell: mv wordpress /var/www/
      
    - name: change owner
      shell: chown -R apache:apache /var/www/html/
      
    - name: change permission
      shell: chmod -R 755 /var/www/html/
      
    - name: link wordpress
      shell: ln -s /var/www/html/wordpress 
      
    - name: restart httpd
      service:
        name: httpd
        state: restarted
더보기
더보기
더보기
  •  

'Linux' 카테고리의 다른 글

[Linux] Docker  (0) 2025.03.20
[Devops] Ansible 기초  (0) 2025.03.06
[Linux] DHCP 설정  (0) 2025.03.04
[Network] offset List  (0) 2025.02.25
[Linux] 메일 서버 구성  (0) 2025.02.19
'Linux' 카테고리의 다른 글
  • [Linux] Docker
  • [Devops] Ansible 기초
  • [Linux] DHCP 설정
  • [Network] offset List
cumo
cumo
  • cumo
    이것저것
    cumo
  • 전체
    오늘
    어제
    • 분류 전체보기 (92) N
      • 이것저것 (1)
      • 보안뉴스 (14)
      • Project (9)
      • wargame (1)
      • Cloud (7)
      • DevOps (11)
      • Linux (20)
      • 네트워크 (23)
      • AWS Developer BootCamp (3) N
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

    • 도구모음 사이트
    • 참고 기술 블로그
  • 공지사항

  • 인기 글

  • 태그

    1
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
cumo
[Devops] Ansible 실습
상단으로

티스토리툴바