Ansible 자동 원격 컴파일이 nginx를 시작합니다.
이 글은 ansible의 자동화된 원격 컴파일과 nginx의 시작을 주로 소개합니다. 이제 특정 참고 가치가 있습니다. 필요한 친구들이 참고할 수 있습니다.
환경: rhel7.3
소프트웨어:
[root@server11 ~]# ansible --versionansible 2.5.3 config file = /etc/ansible/ansible.cfg configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible python version = 2.7.5 (default, Aug 2 2016, 04:20:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]
ssh 비밀번호- free
[root@server11 ansible]# ssh-keygen[root@server11 ansible]# ssh-copy-id 192.168.122.12
파일 디렉터리 구조
[root@server11 ansible]# tree. ├── ansible.cfg├── hosts ├── nginx.yaml└── roles └── nginx ├── default ├── files │ └── nginx-1.13.6.tar.gz ├── handlers ├── meta ├── tasks │ └── main.yml ├── templates │ ├── nginx.conf │ └── nginx.service └── vars └── main.yml9 directories, 8 files
roles/nginx/tasks/main.yml
[root@server11 ansible]# cat roles/nginx/tasks/main.yml - name: copy package copy: src=nginx-1.13.6.tar.gz dest=/usr/local/src/nginx-1.13.6.tar.gz tags: cppkg - name: tar nginx shell: cd /usr/local/src;tar -xf nginx-1.13.6.tar.gz - name: yum install yum: name={{ item }} state=latest with_items: - openssl-devel - pcre-devel - gcc - name: install nginx shell: useradd nginx;cd /usr/local/src/nginx-1.13.6;./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre;make && make install - name: copy conf file template: src=nginx.conf dest=/usr/local/nginx/conf/nginx.conf - name: systemctl init template: src=nginx.service dest=/usr/lib/systemd/system/nginx.service - name: start nginx service service: name=nginx state=started enabled=true
roles/nginx/templates/nginx.conf
[root@server11 ansible]# cat roles/nginx/templates/nginx.conf user nginx; worker_processes {{ ansible_processor_vcpus }}; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 65535; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen {{ nginxport }}; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} }
roles/nginx/templates/nginx.service
[root@server11 ansible]# cat roles/nginx/templates/nginx.service [Unit] Description=The nginx HTTP and reverse proxy server After=network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStartPre=/usr/bin/rm -f /run/nginx.pid ExecStartPre=/usr/local/nginx/sbin/nginx -t ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/bin/kill -s HUP $MAINPID KillMode=process KillSignal=SIGQUIT TimeoutStopSec=5 PrivateTmp=true [Install] WantedBy=multi-user.target
roles/nginx/ vars/ main.yml
[root@server11 ansible]# cat roles/nginx/vars/main.yml nginxport: "80" server_name: "192.168.122.12" root_dir: "/web"
nginx.yaml
[root@server11 ansible]# cat nginx.yaml - hosts: 192.168.122.12 remote_user: root roles: - nginx
관련 권장 사항:
ansible API는 명령의 비동기 실행을 구현합니다
위 내용은 Ansible 자동 원격 컴파일이 nginx를 시작합니다.의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

WPS는 문서, 양식, PPT 등 매우 널리 사용되는 사무용 소프트웨어이며 다중 터미널 동기화를 지원합니다. wps 편집 시 "이 개체에 대한 소스 응용 프로그램을 시작할 수 없습니다"라는 메시지가 나타나는 경우 어떻게 해결합니까? 이 문제는 링크나 파일을 열려고 하지만 해당 소스 응용 프로그램이 더 이상 존재하지 않거나 삭제되었기 때문에 발생할 수 있습니다. 1. WPS 소프트웨어 재설치: WPSOffice를 재설치하여 문제를 해결하고 최신 버전을 사용하고 있는지 확인하십시오. 2. 기본 프로그램 수동 변경: 기본 프로그램을 WPS로 변경해 보십시오. 열려는 파일을 마우스 오른쪽 버튼으로 클릭하고 "다음으로 열기"를 선택한 다음

시스템을 다시 설치하는 것이 완벽한 해결책은 아닐 수 있지만 다시 설치한 후 컴퓨터를 켜면 검은색 배경에 흰색 텍스트가 표시되고 재부팅하고 적절한 부팅 장치를 선택하라는 메시지가 표시됩니다. 무슨 일이 일어나고 있는 걸까요? 이러한 프롬프트는 일반적으로 부팅 오류로 인해 발생합니다. 모두를 돕기 위해 편집자가 해결책을 제시했습니다. 컴퓨터 사용이 점점 더 대중화되고 컴퓨터 오류가 점점 더 흔해지고 있습니다. 아니요, 최근 일부 사용자에게 컴퓨터를 켤 때 검은색 화면이 나타나고 재부팅하고 적절한 부팅 장치를 선택하라는 메시지가 표시되어 컴퓨터 시스템을 시작할 수 없습니다. 보통. 무슨 일이야? 어떻게 해결하나요? 사용자는 혼란스러워하고 다음으로 편집자가 따릅니다.

기술이 계속 발전함에 따라 다양한 운영 체제를 사용해야 하는 필요성이 점점 더 일반화되고 있습니다. Apple 사용자의 경우 때로는 macOS 및 Windows와 같이 하나의 장치에 두 가지 다른 운영 체제를 설치하고 사용해야 할 수도 있습니다. 이 경우 이중 시스템의 시작 순서를 설정하는 것이 특히 중요합니다. 이 문서에서는 장치를 켤 때 먼저 듀얼 시스템을 시작하도록 Apple 장치를 설정하는 방법을 소개합니다. 먼저, 두 운영 체제가 모두 Apple 장치에 성공적으로 설치되었는지 확인해야 합니다. 이 Apple에서는 BootCamp를 사용할 수 있습니다.

wallpaperengine이 시작되면 4가지 옵션이 있습니다. 많은 사용자는 wallpaperengine을 시작할 때 무엇을 선택해야 할지 모릅니다. 일반적으로 wallpaperengine이 시작되면 첫 번째 옵션인 32비트 시작을 선택합니다. wallpaperengine을 시작할 때 무엇을 선택해야 합니까? 답변: 32비트로 시작하세요. 1. 일반적으로 wallpaperengine이 시작되면 첫 번째 항목인 32비트 시작을 선택합니다. 2. wallpaperengine이 시작되면 4가지 옵션이 있습니다: 32비트 시작, 64비트 시작. 3. 32비트 시작: 일반적으로 권장되는 옵션이며 대부분의 사용자에게 적합합니다. 4. 64비트 시작: 시스템이 64비트를 지원하는 경우 이 옵션을 선택할 수 있습니다.

Apple 바로가기 자동화 삭제 방법 Apple의 새로운 iOS13 시스템이 출시되면서 사용자는 바로가기(Apple 바로가기)를 사용하여 다양한 휴대폰 작업을 사용자 정의하고 자동화할 수 있어 사용자의 휴대폰 경험이 크게 향상됩니다. 그러나 때로는 더 이상 필요하지 않은 일부 바로가기를 삭제해야 할 수도 있습니다. 그렇다면 Apple 단축키 명령 자동화를 삭제하는 방법은 무엇입니까? 방법 1: 바로가기 앱을 통해 삭제하세요. iPhone 또는 iPad에서 '바로가기' 앱을 엽니다. 하단 탐색 모음에서 선택

현대 소프트웨어 개발에서 CI(지속적 통합)는 코드 품질과 개발 효율성을 향상시키는 중요한 방식이 되었습니다. 그중 Jenkins는 성숙하고 강력한 오픈 소스 CI 도구로, 특히 PHP 애플리케이션에 적합합니다. 다음 콘텐츠에서는 Jenkins를 사용하여 PHP 지속적 통합을 구현하는 방법을 살펴보고 특정 샘플 코드와 세부 단계를 제공합니다. Jenkins 설치 및 구성 먼저 Jenkins를 서버에 설치해야 합니다. 공식 웹사이트에서 최신 버전을 다운로드하여 설치하세요. 설치가 완료되면 관리자 계정 설정, 플러그인 설치, 작업 구성을 포함한 몇 가지 기본 구성이 필요합니다. 새 작업 만들기 Jenkins 대시보드에서 "새 작업" 버튼을 클릭하세요. "무료"를 선택하세요.

Ansible의 작동 원리는 위 그림에서 이해할 수 있습니다. 관리 측에서는 관리 측에 연결하기 위해 로컬, SSH 및 zeromq의 세 가지 방법을 지원합니다. 기본값은 SSH 기반 연결을 사용하는 것입니다. 위의 아키텍처 다이어그램에서는 HostInventory(호스트 목록) 분류가 다른 방식으로 수행될 수 있습니다. 관리 노드는 단일 모듈 및 단일 명령의 일괄 실행을 구현합니다. -hoc; 관리 노드는 플레이북을 통해 웹 서비스 설치 및 배포, 데이터베이스 서버 일괄 백업 등과 같은 여러 작업 모음을 구현할 수 있습니다. 우리는 플레이북을 시스템이 통과하는 것으로 간단히 이해할 수 있습니다.

공식 문서: https://docs.ansible.com/ansible/latest/command_guide/intro_adhoc.html 소개 Ad-hoc 명령은 일시적으로 입력되고 실행되는 명령으로, 일반적으로 테스트 및 디버깅에 사용됩니다. 간단히 말해서 임시 명령은 "즉시 명령"입니다. 일반적으로 사용되는 모듈 1. 명령 모듈(기본 모듈) 기본 모듈은 쉘만큼 강력하지 않습니다. 기본적으로 쉘 모듈은 명령 모듈의 기능을 지원할 수 있습니다. 【1】Ansible-doccommand# 도움말 다음 ansible-doccomm을 사용하는 것이 좋습니다.
