initial commit
This commit is contained in:
commit
9a87441dde
|
@ -0,0 +1,38 @@
|
|||
Role Name
|
||||
=========
|
||||
|
||||
A brief description of the role goes here.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
|
||||
|
||||
- hosts: servers
|
||||
roles:
|
||||
- { role: username.rolename, x: 42 }
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
BSD
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
# defaults file for im
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
# handlers file for im
|
||||
- name: "Restart im"
|
||||
service:
|
||||
name: im
|
||||
state: restarted
|
||||
when: ansible_service_mgr == "systemd"
|
||||
|
||||
|
||||
- name: "Reload systemd"
|
||||
systemd:
|
||||
daemon_reload: true
|
||||
when: ansible_service_mgr == "systemd"
|
|
@ -0,0 +1,36 @@
|
|||
galaxy_info:
|
||||
role_name: ansible_role_im
|
||||
author: Jens Timmerman
|
||||
description: This role installs the im pantry app (https://gitea.caret.be/jens/im)
|
||||
|
||||
issue_tracker_url: https://gitea.caret.be/jens/im/issues
|
||||
|
||||
# - GPL-3.0-only
|
||||
license: GPL-3.0-only
|
||||
|
||||
min_ansible_version: 2.9
|
||||
|
||||
#
|
||||
# Provide a list of supported platforms, and for each platform a list of versions.
|
||||
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
||||
# To view available platforms and versions (or releases), visit:
|
||||
# https://galaxy.ansible.com/api/v1/platforms/
|
||||
#
|
||||
platforms:
|
||||
- name: Fedora
|
||||
versions:
|
||||
- 32
|
||||
- name: CentOs
|
||||
versions:
|
||||
- 8
|
||||
|
||||
galaxy_tags:
|
||||
- inventory
|
||||
- management
|
||||
- pantry
|
||||
- food
|
||||
|
||||
dependencies: []
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
# if you add dependencies to this list.
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
---
|
||||
# tasks file for im
|
||||
- name: 'install dependencies'
|
||||
package:
|
||||
name:
|
||||
- 'python3-django'
|
||||
- 'curl'
|
||||
- 'tar'
|
||||
- 'psycopg2'
|
||||
- 'gunicorn'
|
||||
state: 'present'
|
||||
|
||||
- name: 'Create im user'
|
||||
user:
|
||||
name: "{{ im_user }}"
|
||||
comment: "im user"
|
||||
home: "{{ im_home }}"
|
||||
shell: "/bin/false"
|
||||
|
||||
- name: 'download latest im stable'
|
||||
get_url:
|
||||
url: https://gitea.caret.be/jens/im/archive/main.tar.gz
|
||||
dest: /tmp/im-latest.tar.gz
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0400'
|
||||
force: true
|
||||
unarchive:
|
||||
src: /tmp/im-latest.tar.gz
|
||||
dest: /home/im/
|
||||
notify: "restart im"
|
||||
|
||||
- name: "Setup systemd service"
|
||||
template:
|
||||
src: im.service.j2
|
||||
dest: /lib/systemd/system/im.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify:
|
||||
- "Reload systemd"
|
||||
- "Restart im"
|
||||
when: ansible_service_mgr == "systemd"
|
||||
|
||||
|
||||
- name: "Configure im"
|
||||
template:
|
||||
src: "{{im_home}}/im/im/settings.py.prod"
|
||||
dest: "{{im_home}}/im/im/settings.py"
|
||||
owner: "{{ im_user }}"
|
||||
mode: 0600
|
||||
notify: "Restart im"
|
||||
vars:
|
||||
- im_secret_key: "{{ lookup('password', im_home + '/.imsecretfile chars=ascii_letters' length=56) }}"
|
||||
|
||||
|
||||
- name: 'migrate django im app'
|
||||
django_manage:
|
||||
- command: migrate
|
||||
django_app: "{{im_home}}"
|
||||
|
||||
- name: 'create superjuser for django im app'
|
||||
django_manage:
|
||||
- command: "createsuperuser --noinput --username=admin --email={{im_admin_email}}"
|
||||
django_app: "{{im_home}}"
|
||||
|
||||
|
||||
- name: 'collect static content'
|
||||
django_manage:
|
||||
- command: "collectstatic"
|
||||
django_app: "{{im_home}}"
|
||||
|
||||
|
||||
|
||||
- name: "Service im"
|
||||
service:
|
||||
name: im
|
||||
state: started
|
||||
enabled: true
|
||||
when: ansible_service_mgr == "systemd"
|
|
@ -0,0 +1,13 @@
|
|||
[Unit]
|
||||
Description=im pantry inventory management server trought gunicorn
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User={{ gitea_user }}
|
||||
WorkingDirectory={{ gitea_home }}
|
||||
ExecStart=/usr/local/bin/gunicorn --workers {{im_workers}} --bind {{ im_http_listen }}:{{ im_http_port }} im.wsgi:application
|
||||
Restart=on-failure
|
||||
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -0,0 +1,2 @@
|
|||
localhost
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- im
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
# vars file for im
|
Loading…
Reference in New Issue