ansible 安装架构汇总(ansible汇总)

ansible 网站架构实操

编辑: https://www.baimeidashu.com/wp-admin/post.php?post=8582&action=edit

ansible 安装:   ansible安装部署

anible:初始化框架:

ansible-galaxy init nfs (初始化 项目框架)
rm -rf defaults/ meta/ README.md 

 

运行:

ansible-playbook /etc/ansible/roles/site.yml

检测:

ansible-playbook --syntax-check /etc/ansible/roles/site.yml

 

ansible 构建 web 架构

1  环境配置, basic:  步骤

2- 服务安装

ansible   安装NFS : 步骤

ansible 安装 rsync: 步骤

ansible 安装 PHP : 步骤

ansible 安装 nginx : 步骤

ansible 安装 mysql: 步骤

ansible 安装 sersync : 步骤

ansible 安装 ssl 实现https访问: 步骤

 

3 :业务安装:

wordpress 安装: 步骤     (chaoren399, 123456)

负载均衡 业务(web01,web02): 步骤

高可用 业务 lb01,lb02 : 步骤       (ip a | grep 10.0.0.3)

会话保持 安装 ( Redis), 步骤      (baimei, 123456) 遇到问题: 负载均衡发现问题

4 : 扩展:

yum 本地仓库配置: 步骤

时间同步服务器: 步骤 

zabbix 安装: 步骤

 

总结:

一般来讲,当task失败时,ansible会停止执行失败的那台主机上的任务,但是继续对其他 主机执行

 

遇到的问题:

安装完 程序后, 只希望执行一次 文件 复制命令, 或者其他的 配置动作  比如mysql 可参考

 

 

 

 

iptables 共享上网, 其他主机不能上网, 如何通过iptables 来让 其他主机上网呢?

步骤

 

 

相关的 命令:总结:

多次复制 + 通知 :

- name: copy rsync configure File
  template:
        src: "{{ item.src }}"
        dest: "{{ item.dest }}"
        mode: "{{ item.mode}}"
  loop:
    - {src: rsyncd.conf.j2, dest: /etc/rsyncd.conf, mode: '0644'}
    - {src: rsync.passwd.j2, dest: /etc/rsync.passwd,mode: '0600'}
  notify: Restart Rsyncd Server

hadler:

[root@m01 /etc/ansible/roles]#cat  rsync/handlers/main.yml 
- name: Restart Rsyncd Server
  systemd:
        name: rsyncd
        state: restarted

复制多个文件 () : 注意 copy  是没有变量, template 是有变量的

- name: copy php.ini www.conf
  copy:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
  with_items:
    - { src: 'php.ini', dest: '/etc/php.ini' }
    - { src: 'www.conf', dest: '/etc/php-fpm.d/www.conf' }
  when: ansible_hostname is match "web*"
  notify: Restart php-fpm

debug:

ansible 使用if判断 生成不同的配置文件:

https://www.baimeidashu.com/8711.html

解压:

- name: unarchive wordpress_code.tar
  unarchive:
   src: wordpress_1.tar.gz
   dest: /code/
   creates: /code/wordpress/
  notify: mount nfs

 

执行命令:

- name: file miaoshufu 65535
  shell:
    cmd: echo '* - nofile 65535' >> /etc/security/limits.conf

 

copy  复制:

      copy: 
        src: exports
        dest: /etc/

 

检查ping:

ansible all -m ping

 

php71.tar.gz: https://url69.ctfile.com/f/253469-846055569-076bb9?p=2206 (访问密码: 2206)

 

ansible 管理机 需要的环境: 步骤

ansible管理机所有的文件:

ansibleall.tar.gz:

https://url69.ctfile.com/f/253469-851700525-e794e6?p=2206 (访问密码: 2206)

欢迎来撩 : 汇总all

白眉大叔

关于白眉大叔linux云计算: 白眉大叔

热门文章