日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
linux如何使用Ansible讓系統(tǒng)管理自動化

Ansible簡介

Ansible是一個開源的IT自動化工具,用于配置管理、應(yīng)用部署、任務(wù)執(zhí)行和多節(jié)點協(xié)調(diào),通過SSH協(xié)議,可以在遠程服務(wù)器上以安全的方式執(zhí)行命令,實現(xiàn)對系統(tǒng)資源的管理,Ansible使用YAML語言編寫的Playbook來描述任務(wù)流程,可以輕松地將任務(wù)模塊化、可重復(fù)使用和可擴展。

站在用戶的角度思考問題,與客戶深入溝通,找到湛江網(wǎng)站設(shè)計與湛江網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:成都做網(wǎng)站、網(wǎng)站設(shè)計、外貿(mào)營銷網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、域名申請、雅安服務(wù)器托管、企業(yè)郵箱。業(yè)務(wù)覆蓋湛江地區(qū)。

Ansible安裝與配置

1、安裝Ansible

在Linux系統(tǒng)中,可以通過以下命令安裝Ansible:

sudo apt-get update
sudo apt-get install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt-get install ansible

2、配置Ansible

在安裝完成后,需要對Ansible進行基本配置,編輯/etc/ansible/ansible.cfg文件,設(shè)置以下參數(shù):

[defaults]
inventory = /etc/ansible/hosts
remote_user = root
private_key_file = ~/.ssh/id_rsa

3、創(chuàng)建主機清單文件

/etc/ansible/hosts文件中,添加主機信息。

[group1]
host1 ansible_host=192.168.1.1 ansible_user=root ansible_connection=local
host2 ansible_host=192.168.1.2 ansible_user=root ansible_connection=local
[group2]
host3 ansible_host=192.168.1.3 ansible_user=root ansible_connection=local
host4 ansible_host=192.168.1.4 ansible_user=root ansible_connection=local

使用Ansible編寫Playbook

1、創(chuàng)建Playbook文件

使用文本編輯器創(chuàng)建一個名為example.yml的Playbook文件,編寫以下內(nèi)容:


name: Install Nginx
  hosts: all
  tasks:
    name: Update package list
      apt:
        name: "{{ item }}" state=present update_cache=yes
      with_items:
        nginx
        php-fpm php-mysqlnd php-gd php-xml php-mbstring php-curl php-bcmath php-ldap php-json php-tokenizer php-mcrypt php-apcu php-intl php-soap curl php-dev libxml2 zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev wget git libc6 libncurses5-dev unzip automake libtool bison subversion python3 python3-pip python3-dev python3-venv zip g++ make cmake libboost-all-dev libbz2-dev libffi-dev libpq-dev nodejs npm supervisor virtualenv python3-venv python3-setuptools pip xz-utils tar git mercurial orwpan emacs emacs24 m4 libgtk2.0-dev libwebkitgtk-dev libnotify-dev libnss3-dev libxslt1.1 libxml2-dev libxsltproc-dev libgconf2-dev libgdk-pixbuf2.0-dev libpangocairo-1.0-0 libatk1.0-0 libatkmm1.6-1 libgtk2.0-0 libpcre3-dev libjpeg62 libcap2-bin zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc zlib1g zlibc --with-openssl --with-python --with-python3 --with-systemd --with-systemdsystemunitdir=/usr/share/systemd/system --with-selinux --with-selinuxtypes --with-cacertdir=/etc/ssl/certs --with-cacert=/etc/ssl/certs/cacert.pem --with-validationchecksum true 
      git clone https://github.com/ansible/ansible.git $HOME/ansible 
      cd $HOME/ansible && git checkout release/2.9 
      cd $HOME/ansible && git pull origin master 
      cd $HOME/ansible && make && make install 
      mkdir ~/.ansible 
      cp ~/.vimrc ~/.emacs ~/.inputrc ~/.profile ~/.bashrc ~/.bash_profile ~/.bash_login ~/.config/fish/config.fish ~/.config/polybar/launch.sh ~ 
      chown root:root * 
      chmod go+rwx * 
"
     become: yes become_method: sudo 
     become_user: root 
     when: "'group1|group2' in groupnames" 
     become_ask_pass: yes
     become_pass: "{{ lookup('passwordfile', 'admin') | b64decode('utf-8') }}
"
     notify:
         Reload Nginx
         Run Service
         SSH Reconnect
     tasks:
        -
            ping:
                host: localhost
                register: result
                ignore_errors: yes
            Debug:
                var: result.stdout_lines
        name: Install Nginx
          nginx:
            enabled: yes
            state: present
            update_cache: yes
            enablerepo: extras
            docroot: /var/www/html
            errorlog: /var/log/nginx/error.log
            accesslog: /var/log/nginx/access.log
            http_proxy: http://{{ inventory_hostname }}
            https_proxy: https://{{ inventory_hostname }}
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            auth_basic "Restricted";
            auth_basic_user_file /etc/nginx/htpasswd;
            keepalive_timeout 65;
            listen [::]:80 default_server;
            listen [::]:443 default_server {
                return ("HTTPS required")
            }
         notify:
             Reload Nginx
         runservice:
             name: service apache2 restart
pip install requests==2.25.1
pip freeze > requirements.txt
cd ~ && git clone https://github.com/jakevdp/
gitbucket gitbucket
cd gitbucket && git remote add upstream https://github.com/jakevdp/
gitbucket && git fetch upstream && git rebase upstream/master --autostash --keep-index && git push origin master --force --quiet --set-upstream origin master && cd ~ && pip install dist/*whl >> requirements.txt
cd $HOME && git add requirements.txt && git commit -
adcommit message="Upgrade dependencies" && git push origin master --force --quiet --set-upstream origin master && cd ~ && pip install virtualenvwrapper >> requirements.txt && echo export WORKON_HOME=$HOME >> ~.bashrc && echo export VIRTUALENVWRAPPER_PYTHON=python3 >> ~.bashrc && source ~.bashrc && workon venv && cd venv && source bin/activate && pip install wheel >> requirements.txt && pip wheel * >> requirements.txt && deactivate
noopierun pip install --requirement

網(wǎng)頁標(biāo)題:linux如何使用Ansible讓系統(tǒng)管理自動化
文章URL:http://www.5511xx.com/article/dpseejc.html