ansible-nginx/tests/includes/pre_common.yml

60 lines
1.5 KiB
YAML
Raw Normal View History

2018-03-17 03:56:15 +07:00
---
2023-05-30 23:30:49 +07:00
- name: COMMAND | Start ngrok
ansible.builtin.command: daemonize -l /tmp/ngrok.lock {{ ngrok_path }} http 80 --scheme http
2018-03-17 03:56:15 +07:00
failed_when: false
changed_when: ngrok.stderr.find("Can't lock the lock file") == -1
register: ngrok
2023-05-30 23:30:49 +07:00
- name: WAIT_FOR | ngrok started # noqa: no-handler
2023-05-30 20:28:55 +07:00
ansible.builtin.wait_for:
2018-03-17 03:56:15 +07:00
delay: 2
port: 4040
when: ngrok.changed
- name: SHELL | Get ngrok public address
2023-05-30 20:28:55 +07:00
ansible.builtin.shell: set -o pipefail && curl 'http://127.0.0.1:4040/api/tunnels/command_line' 2> /dev/null | jq -r '.public_url' | cut -d '/' -f 3
args:
2021-09-01 16:02:12 +07:00
executable: /bin/bash
2018-03-17 03:56:15 +07:00
register: ngrok
changed_when: false
2021-09-10 21:25:01 +07:00
- name: FILE | Create an internal SSL dir
ansible.builtin.file:
path: "{{ int_ansible_ssl_dir }}"
state: directory
mode: 0750
owner: root
group: root
2023-05-30 23:30:49 +07:00
- name: COPY | Deploy test cert/key
2021-09-10 21:25:01 +07:00
ansible.builtin.copy:
2023-05-30 23:30:49 +07:00
src: "file/{{ item }}"
dest: "{{ int_ansible_ssl_dir }}/{{ item }}"
2021-09-10 21:25:01 +07:00
mode: 0640
owner: root
group: root
2023-05-30 23:30:49 +07:00
loop:
- 'test.key'
- 'test.crt'
2021-09-10 21:25:01 +07:00
- name: COPY | Add all hosts in /etc/hosts
ansible.builtin.copy:
content: |
127.0.0.1 localhost
{% for s in nginx_sites %}
{% if s.name is string %}
127.0.0.1 {{ s.name }}
{% else %}
127.0.0.1 {% for n in s.name %}{{ n }} {% endfor %}
{% endif %}
{% if s.redirect_from is defined %}
127.0.0.1 {% for rf in s.redirect_from %}{{ rf }} {% endfor %}
{% endif %}
{% endfor %}
dest: "/etc/hosts"
mode: 0644
owner: root
group: root
unsafe_writes: true