openstack-ansible-repo_server/tasks/repo_post_install.yml
Logan V 68e8cc6854 Use ansible_service_mgr fact
This patch removes some extra tasks for detecting systemd and uses
the  fact instead.

Partial-Bug: #1640125
Change-Id: I213b38b166de724990958a316e577478d7e4823c
2016-11-10 07:22:32 +00:00

178 lines
4.9 KiB
YAML

---
# Copyright 2016, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: create the system group
group:
name: "{{ repo_service_group_name }}"
state: "present"
system: "yes"
tags:
- pkg-repo-group
- name: Remove old key file(s) if found
file:
path: "{{ item }}"
state: "absent"
with_items:
- "{{ repo_service_home_folder }}/.ssh/authorized_keys"
- "{{ repo_service_home_folder }}/.ssh/id_rsa"
- "{{ repo_service_home_folder }}/.ssh/id_rsa.pub"
when: repo_recreate_keys | bool
tags:
- repo-key
- repo-key-create
- name: Create the nginx system user
user:
name: "{{ repo_service_user_name }}"
group: "{{ repo_service_group_name }}"
comment: "Nginx repo user"
shell: "/bin/bash"
system: "yes"
createhome: "yes"
home: "{{ repo_service_home_folder }}"
generate_ssh_key: "yes"
tags:
- pkg-repo-user
- repo-key
- repo-key-create
- name: File and directory setup (non-root user)
file:
path: "{{ item.path }}"
state: "{{ item.state }}"
owner: "{{ repo_service_user_name }}"
group: "{{ repo_service_group_name }}"
mode: "{{ item.mode | default('02755') }}"
with_items:
- path: "{{ repo_service_home_folder }}"
state: "directory"
- path: "{{ repo_service_home_folder }}/.ssh"
state: "directory"
mode: "02700"
- path: "{{ repo_service_home_folder }}/repo"
state: "directory"
- path: "{{ repo_service_home_folder }}/repo/links"
state: "directory"
- path: "{{ repo_service_home_folder }}/repo/os-releases"
state: "directory"
- path: "{{ repo_service_home_folder }}/repo/os-releases/{{ openstack_release }}"
state: "directory"
- path: "{{ repo_service_home_folder }}/repo/pools"
state: "directory"
- path: "/var/log/nginx"
state: "directory"
mode: "0775"
tags:
- pkg-repo-dirs
- name: Check if the git folder exists already
stat:
path: "{{ repo_service_home_folder }}/repo/openstackgit"
register: _git_folder
tags:
- pkg-repo-dirs
- name: Git service data folder setup
file:
path: "{{ (_git_folder.stat.exists and _git_folder.stat.islnk) | ternary(_git_folder.stat.lnk_source, repo_service_home_folder + '/repo/openstackgit') }}"
state: "directory"
owner: "{{ repo_service_user_name }}"
group: "{{ repo_service_group_name }}"
recurse: true
tags:
- pkg-repo-dirs
- name: File and directory setup (root user)
file:
path: "{{ item.path }}"
state: "{{ item.state }}"
owner: "root"
group: "root"
mode: "{{ item.mode | default(omit) }}"
with_items:
- path: "/etc/lsyncd"
state: "directory"
mode: "0755"
- path: "/var/log/lsyncd"
state: "directory"
mode: "0755"
- path: "/etc/nginx/sites-enabled/default"
state: "absent"
- path: "/etc/nginx/sites-available"
state: "directory"
mode: "0644"
- path: "/etc/nginx/sites-enabled"
state: "directory"
mode: "0644"
- name: Drop NGINX configuration files
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
with_items:
- { src: "nginx.conf.j2", dest: "/etc/nginx/nginx.conf" }
- { src: "rsyncd.conf.j2", dest: "/etc/rsyncd.conf" }
- { src: "openstack-slushee.vhost.j2", dest: "/etc/nginx/sites-available/openstack-slushee.vhost" }
notify:
- reload nginx
tags:
- pkg-repo-nginx
- pkg-repo-config
- name: Enable openstack-slushee site
file:
src: "/etc/nginx/sites-available/openstack-slushee.vhost"
dest: "/etc/nginx/sites-enabled/openstack-slushee.vhost"
state: "link"
notify:
- reload nginx
tags:
- pkg-repo-nginx
- pkg-repo-config
- name: Place git daemon upstart init script
template:
src: "git-daemon-upstart-init.j2"
dest: "/etc/init/git-daemon.conf"
mode: "0644"
owner: "root"
group: "root"
when:
- ansible_service_mgr == 'upstart'
- ansible_distribution == "Ubuntu"
notify:
- Init reload
- reload git-daemon
tags:
- git-daemon-init
- name: Place git daemon upstart init script
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "0644"
owner: "root"
group: "root"
with_items:
- { src: "git.service.j2", dest: "/lib/systemd/system/git@.service" }
- { src: "git.socket.j2", dest: "/lib/systemd/system/git.socket" }
when:
- ansible_service_mgr == 'systemd'
notify:
- reload git socket
tags:
- git-daemon-init