You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.3 KiB
48 lines
1.3 KiB
---
|
|
- name: Converge
|
|
hosts: all
|
|
remote_user: ansible
|
|
become: yes
|
|
tasks:
|
|
- name: Update apt cache
|
|
apt:
|
|
update_cache: yes
|
|
cache_valid_time: 600
|
|
become: yes
|
|
when: ansible_os_family == 'Debian'
|
|
changed_when: false
|
|
|
|
- name: Install python packages
|
|
apt:
|
|
name:
|
|
- "python{{ '3' if ansible_python.version.major == 3 else '' }}-dev"
|
|
- "python{{ '3' if ansible_python.version.major == 3 else '' }}-setuptools"
|
|
- "python{{ '3' if ansible_python.version.major == 3 else '' }}-pip"
|
|
|
|
- name: "Create directories"
|
|
file:
|
|
path: /var/www/{{ item }}
|
|
state: directory
|
|
loop:
|
|
- static
|
|
- media
|
|
|
|
- name: "Create test file"
|
|
copy:
|
|
dest: /var/www/{{ item.directory }}/{{ item.file }}
|
|
content: "{{ item.directory }}"
|
|
loop:
|
|
- directory: static
|
|
file: static.html
|
|
- directory: static
|
|
file: cache.js
|
|
- directory: static
|
|
file: cache.css
|
|
- directory: media
|
|
file: media.html
|
|
- debug:
|
|
var: ansible_python
|
|
- name: Run simple python server
|
|
shell:
|
|
cmd: "nohup {{ ansible_python.executable }} -m {{ 'http.server' if ansible_python.version.major == 3 else 'SimpleHTTPServer'}} &"
|
|
chdir: /tmp
|
|
|