From aac14db6572b80558b2bd01603b7c20cef728d61 Mon Sep 17 00:00:00 2001 From: Timo Makinen Date: Sat, 29 Aug 2020 13:43:21 +0000 Subject: [PATCH] ansible-host: Publish ansible facts with nginx --- roles/ansible-host/files/nginx.conf | 4 ++++ roles/ansible-host/meta/main.yml | 1 + roles/ansible-host/tasks/main.yml | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 roles/ansible-host/files/nginx.conf diff --git a/roles/ansible-host/files/nginx.conf b/roles/ansible-host/files/nginx.conf new file mode 100644 index 0000000..218fbd1 --- /dev/null +++ b/roles/ansible-host/files/nginx.conf @@ -0,0 +1,4 @@ +location /facts { + autoindex on; + autoindex_format json; +} diff --git a/roles/ansible-host/meta/main.yml b/roles/ansible-host/meta/main.yml index 9fd1e75..4db02d4 100644 --- a/roles/ansible-host/meta/main.yml +++ b/roles/ansible-host/meta/main.yml @@ -1,3 +1,4 @@ --- dependencies: - { role: epel-repo } + - { role: nginx/server } diff --git a/roles/ansible-host/tasks/main.yml b/roles/ansible-host/tasks/main.yml index 72f7a3e..a5d426c 100644 --- a/roles/ansible-host/tasks/main.yml +++ b/roles/ansible-host/tasks/main.yml @@ -30,12 +30,34 @@ state: link follow: false +- name: allow http server to access /srv/ansible + sefcontext: + path: /srv/ansible(/.*)? + setype: httpd_sys_content_t - name: clone ansible repository git: dest: /srv/ansible repo: https://git.foo.sh/ansible.git update: false +- name: link facts to nginx + file: + src: "/srv/ansible/facts" + dest: "/srv/web/{{ inventory_hostname }}/facts" + owner: root + group: "{{ ansible_wheel }}" + state: link + follow: false + +- name: create nginx conf + copy: + src: nginx.conf + dest: /etc/nginx/conf.d/{{ inventory_hostname }}/ansible.conf + mode: 0644 + owner: root + group: "{{ ansible_wheel }}" + notify: restart nginx + - name: add custom .bashrc for root copy: dest: /root/.bashrc