Ansible-完成kodcloud项目部署

1.roles/kodcloud/tasks/main.yml

`# 创建虚拟主机
echo '
server {
        listen 80;
        server_name kod.imscz.com;
        root /code/kod;

        location / {
                index   index.php index.html;

        }
        location ~ .*\.php$ {
                fastcgi_pass    127.0.0.1:9000;
                fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include         fastcgi_params;
                fastcgi_param   HTTPS on;
        }
}
' > /etc/nginx/conf.d/kod.imscz.com.conf

`# 创建站点目录
mkdir /code/kod -p

`# 上传可道云源码至站点目录
cd /code/kod
sz...略
tar -xzvf kod.tar.gz
chown www.www -R /code/kod


`# 重启nginx服务
systemctl restart nginx
- name: Create kod virtual hosts
  copy:
    src: kod.imscz.com.conf
    dest: /etc/nginx/conf.d/kod.imscz.com.conf

- name: Create site directory
  file:
    path: /code/kod
    state: directory
    recurse: yes
    owner: www
    group: www

- name: Upload kod source_code
  unarchive:
    src: kod.tar.gz
    dest: /code/kod
    owner: www
    group: www

- name: Create nfs_mount_directory
  file:
    path: /mnt/kod
    state: directory
    owner: www
    group: www
    recurse: yes

- name: Mount nfs_share_directory to local_mount_directory
  mount:
    src: 172.16.1.31:/data/kod
    path: /mnt/kod
    fstype: nfs
    state: mounted

- name: Restart nginx
  systemd:
    name: nginx
    state: restarted

2.roles/kodcloud/files/

# 虚拟主机配置文件
kod.imscz.com.conf

# 可道云源码布署压缩包,此包为提前部署好的源码进行压缩而成
kod.tar.gz

猜你喜欢

转载自www.cnblogs.com/IMSCZ/p/12133961.html