diff --git a/provisioning/group_vars/all b/provisioning/group_vars/all index 057f8b3..3ea60f4 100644 --- a/provisioning/group_vars/all +++ b/provisioning/group_vars/all @@ -1 +1,2 @@ -shelfzilla_base_path: /opt/shelfzilla \ No newline at end of file +shelfzilla_base_path: /opt/shelfzilla +system_init_path: /etc/init.d \ No newline at end of file diff --git a/provisioning/roles/shelfzilla/handlers/main.yml b/provisioning/roles/shelfzilla/handlers/main.yml new file mode 100644 index 0000000..d02ba43 --- /dev/null +++ b/provisioning/roles/shelfzilla/handlers/main.yml @@ -0,0 +1,4 @@ +--- +- name: restart postgresql + service: name=postgresql state=restarted + sudo: yes \ No newline at end of file diff --git a/provisioning/roles/shelfzilla/tasks/main.yml b/provisioning/roles/shelfzilla/tasks/main.yml new file mode 100644 index 0000000..bbe3833 --- /dev/null +++ b/provisioning/roles/shelfzilla/tasks/main.yml @@ -0,0 +1,6 @@ +--- +- debug: msg="Starting Shelfzilla module" +- include: shelfzilla.yml +#- include: npm_dependencies.yml +#- include: pip_dependencies.yml +#- include: postgre.yml diff --git a/provisioning/roles/shelfzilla/tasks/npm_dependencies.yml b/provisioning/roles/shelfzilla/tasks/npm_dependencies.yml new file mode 100644 index 0000000..bbf503b --- /dev/null +++ b/provisioning/roles/shelfzilla/tasks/npm_dependencies.yml @@ -0,0 +1,6 @@ +- name: Install NodeJS and NPM packages + yum: pkg={{item}} state=installed + sudo: yes + with_items: + - nodejs + - npm \ No newline at end of file diff --git a/provisioning/roles/shelfzilla/tasks/pip_dependencies.yml b/provisioning/roles/shelfzilla/tasks/pip_dependencies.yml new file mode 100644 index 0000000..12416c5 --- /dev/null +++ b/provisioning/roles/shelfzilla/tasks/pip_dependencies.yml @@ -0,0 +1,13 @@ +- name: Install Python27 packages + yum: pkg={{item}} state=installed + sudo: yes + with_items: + - python27 + - python27-tools + - python27-devel + - python27-libs + - python27-setuptools + +- easy_install: name=pip executable=/usr/bin/easy_install-2.7 + sudo: yes + diff --git a/provisioning/roles/shelfzilla/tasks/postgre.yml b/provisioning/roles/shelfzilla/tasks/postgre.yml new file mode 100644 index 0000000..c86eab5 --- /dev/null +++ b/provisioning/roles/shelfzilla/tasks/postgre.yml @@ -0,0 +1,41 @@ +--- +- name: Install PostgreSQL packages + yum: pkg={{item}} state=installed + sudo: yes + with_items: + - postgresql + - postgresql-server + - python-psycopg2 + - postgresql-contrib + - postgresql-libs + - postgresql-devel + +- name: Initiate PostgreSQL database + action: shell /sbin/service postgresql initdb + creates=/var/lib/pgsql/data/postgresql.conf + sudo: yes + notify: + - restart postgresql + +- meta: flush_handlers + +- lineinfile: "dest=/etc/sudoers regexp='^%vagrant' state=present line='%vagrant ALL = (postgres) NOPASSWD: ALL'" + sudo: yes + when: local_environment + +- name: ensure database is created + postgresql_db: name={{dbname}} + sudo: yes + sudo_user: postgres + +- name: ensure user has access to database + postgresql_user: db={{dbname}} name={{dbuser}} priv=ALL + sudo_user: postgres + sudo: yes + +- name: ensure user does not have unnecessary privilege + postgresql_user: name={{dbuser}} role_attr_flags=NOSUPERUSER,NOCREATEDB + sudo_user: postgres + sudo: yes + + diff --git a/provisioning/roles/shelfzilla/tasks/shelfzilla.yml b/provisioning/roles/shelfzilla/tasks/shelfzilla.yml new file mode 100644 index 0000000..f89cd14 --- /dev/null +++ b/provisioning/roles/shelfzilla/tasks/shelfzilla.yml @@ -0,0 +1,35 @@ +--- +- name: Install shelfzilla RPM + yum: pkg=shelfzilla state=installed + sudo: yes + +- name: Move Shelfzilla init script + command: mv {{shelfzilla_base_path}}/init/shelfzilla {{system_init_path}}/shelfzilla + sudo: yes + +- name: Change Permission of init script + file: path={{system_init_path}}/shelfzilla + owner=root + group=root + mode=0755 + sudo: yes + +- name: Load Shelfzilla service in boot + service: name=shelfzilla + pattern={{system_init_path}}/shelfzilla + enabled=yes + sudo: yes + +- name: delete init directory + file: path={{items}} state=absent recurse=no + sudo: yes + with_items: + - {{shelfzilla_base_path}}/init/shelfzilla + - {{shelfzilla_base_path}}/init + + + +mv %{_app_dir}/init/shelfzilla %{_init_path}/ +chmod 775 %{_init_path}/shelfzilla +chkconfig --add shelfzilla +rmdir %{_app_dir}/init/ \ No newline at end of file diff --git a/provisioning/roles/shelfzilla/templates/shelfzilla.repo b/provisioning/roles/shelfzilla/templates/shelfzilla.repo new file mode 100644 index 0000000..40a3170 --- /dev/null +++ b/provisioning/roles/shelfzilla/templates/shelfzilla.repo @@ -0,0 +1,5 @@ +[Shelfzilla] +name=Shelfzilla Awesome App +baseurl=http://37.139.15.172/ +gpgcheck=0 +enabled=1 \ No newline at end of file diff --git a/provisioning/roles/shelfzilla/vars/main.yml b/provisioning/roles/shelfzilla/vars/main.yml new file mode 100644 index 0000000..852b0ed --- /dev/null +++ b/provisioning/roles/shelfzilla/vars/main.yml @@ -0,0 +1,4 @@ +--- +## PostgreSQL Variables +dbname: shelfzilla +dbuser: shelfzilla \ No newline at end of file diff --git a/provisioning/site.yml b/provisioning/site.yml index cb8a5db..9a61334 100644 --- a/provisioning/site.yml +++ b/provisioning/site.yml @@ -4,6 +4,7 @@ roles: - role: common - role: shelfzilla_base + - role: shelfzilla - name: Production Task hosts: production