zoukankan      html  css  js  c++  java
  • 拿到新机器,进行初始化和部署Nginx的过程

    1. 在/etc/ansbile/hosts中添加主机init

    2. 在sysinit.yml中修改要初始化的机器:
       hosts: init

    3. 设置不检查key   
       export ANSIBLE_HOST_KEY_CHECKING=False

    4. 因为开启了selinux,所以需要安装libselinux-python
       ansible init -m shell -a 'yum install libselinux-python -y' -k

    5. 执行初始化
      ansible-playbook sysinit.yml -k
       
    6. 复制key到主机
       ssh-copy-id -i "/root/.ssh/id_rsa.pub" "-p 50000 lsyw@162.221.12.108"

    7. 测试key通信
       ####重新在hosts中编辑一个组nginx,然后配置group_vars:
       ansible_user: lsyw
       ansible_port: 50000
       ansible_su_password: "0xxxxx"

       ansible nginx -m ping

    8. 安装nginx
       在tengine_comm_deploy.yml中修改hosts为nginx
       执行命令:ansible-playbook tengine_comm_deploy.yml -S
       
    9. 部署d9导航页
       cd /root/distri     #切换到ansible源代码存放目录
       rz -y          #上传源代码到ansible主机
       ansible nginx -S -R root -m unarchive -a "src=d9_201608311030.zip  dest=/data"
       ansible nginx -S -R root -m shell -a "ln -s /data/d9_201608311030 /data/www"

       更新nginx配置文件:
        ansible nginx -S -R root -m shell -a "rm -rf /usr/local/gacp/nginx/conf/vhosts.d/*"
        ansible nginx -S -R root -m copy -a "src=www.d9.com.conf dest=/usr/local/gacp/nginx/conf/vhosts.d/"
        ansible nginx -S -R root -m shell -a "/sbin/service nginx reload"
        ansible nginx -S -R root -m shell -a "netstat -nl "

    10. 添加防火墙
        ansible nginx -S -R root -m shell -a "/sbin/iptables -I INPUT 5 -p tcp --dport 80 -m state --state NEW -j ACCEPT"
        ansible nginx -S -R root -m shell -a "/sbin/service iptables save"

  • 相关阅读:
    hdu 2489 dfs枚举组合情况+最小生成树
    hdu3938 Portal 离线的并查集
    hdu3926 Hand in Hand 判断同构
    hdu1811 Rank of Tetris 拓扑排序+并查集
    poj3083 Children of the Candy Corn 深搜+广搜
    HDU 2529 Shot (物理数学题)
    HDU 4576 Robot(概率dp)
    HDU 2672 god is a girl (字符串处理,找规律,简单)
    HDU 2669 Romantic(扩展欧几里德, 数学题)
    HDU 2671 Can't be easier(数学题,点关于直线对称)
  • 原文地址:https://www.cnblogs.com/zhaojonjon/p/5830463.html
Copyright © 2011-2022 走看看