Ansible-kodcloudプロジェクトの導入を完了

1573 ワード

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