Skip to content
Snippets Groups Projects
Commit df47d29b authored by nimrod's avatar nimrod
Browse files

Merge branch 'master' of /home/nimrod/Documents/Shore/Ansible/ansible-role-example

parents 9126d19d 7e3b6b88
No related branches found
No related tags found
No related merge requests found
*.sw[po]
~* ~*
*~ *~
*.swp .DS_Store
*.swo __pycache__
*.py[cod]
.cache/
.molecule/
.vagrant/
*.log
*.retry
- repo: git://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
sha: cf550fcab3f12015f8676b8278b30e1a5bc10e70 sha: 6dfcb89af3c9b4d172cc2e5a8a2fa0f54615a338
hooks: hooks:
- id: check-added-large-files - id: check-added-large-files
- id: check-json - id: check-json
- id: check-xml - id: check-xml
- id: check-yaml - id: check-yaml
- id: check-merge-conflict - id: check-merge-conflict
- repo: https://www.shore.co.il/git/ansible-pre-commit/
sha: 94b506c144d4e22ebc1deef637a818db13bcaca5
hooks:
- id: ansible-pre-commit
The MIT License (MIT) The MIT License (MIT)
Copyright (c) [year] [fullname] Copyright (c) 2016 Adar Nimrod
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
......
ansible-mysql MySQL
############# #####
An Ansible role to install and configure a MySQL server. The role creates an An Ansible role to install and configure a MySQL server. The role creates an
admin account, force SSL usage, configures UFW and daily backup. admin account, force SSL usage, configures UFW and daily backup.
...@@ -7,47 +7,43 @@ admin account, force SSL usage, configures UFW and daily backup. ...@@ -7,47 +7,43 @@ admin account, force SSL usage, configures UFW and daily backup.
Requirements Requirements
------------ ------------
Debian Wheezy or later (Ubuntu Precise or later should probably work, but it's See :code:`meta/main.yml` and assertions at top of :code:`tasks/main.yml`.
untested).
Role Variables Role Variables
-------------- --------------
::
mysql_admin_password: #The password for the admin account. See :code:`defaults/main.yml`.
Dependencies Dependencies
------------ ------------
`Common role <https://www.shore.co.il/cgit/ansible-common/>`_ See :code:`meta/main.yml`.
Example Playbook Example Playbook
---------------- ----------------
::
- hosts: servers See :code:`tests/playbook.yml`.
roles:
- role: mysql
mysql_admin_password: qwerty123
Example requirements.yml Testing
------------------------ -------
::
To install the dependencies:
.. code:: shell
ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles
- src: https://www.shore.co.il/cgit/ansible-common To run the full test suite:
scm: git
path: roles/
name: common
- src: https://www.shore.co.il/cgit/ansible-mysql .. code:: shell
scm: git
path: roles/ molecule test
name: mysql
License License
------- -------
This software is licnesed under the MIT licese (see the ``LICENSE.txt`` file). This software is licensed under the MIT license (see the :code:`LICENSE.txt`
file).
Author Information Author Information
------------------ ------------------
...@@ -55,12 +51,4 @@ Author Information ...@@ -55,12 +51,4 @@ Author Information
Nimrod Adar, `contact me <nimrod@shore.co.il>`_ or visit my `website Nimrod Adar, `contact me <nimrod@shore.co.il>`_ or visit my `website
<https://www.shore.co.il/>`_. Patches are welcome via `git send-email <https://www.shore.co.il/>`_. Patches are welcome via `git send-email
<http://git-scm.com/book/en/v2/Git-Commands-Email>`_. The repository is located <http://git-scm.com/book/en/v2/Git-Commands-Email>`_. The repository is located
at: https://www.shore.co.il/cgit/. at: https://www.shore.co.il/git/.
TODO
----
- Don't set a password for the root account, it's only accessible from the
machine itself. Instead create an admin account, without root priviliges and
with mandatory SSL for connecting. Also, other roles will set mandatory SSL
for their connections.
[defaults]
host_key_checking = False
retry_files_enabled = False
roles_path = roles:../:../../:.molecule/roles
command_warnings = True
deprecation_warnings = True
--- ---
# defaults file for ansible-mysql # defaults file for ansible-role-mysql
mysql_admin_password: mysql_admin_password:
--- ---
# handlers file for ansible-mysql # handlers file for ansible-role-mysql
- name: Restart MySQL - name: Restart MySQL
service: service:
......
...@@ -4,7 +4,7 @@ galaxy_info: ...@@ -4,7 +4,7 @@ galaxy_info:
description: MySQL role. For more information read the README file. description: MySQL role. For more information read the README file.
company: Shore technologies company: Shore technologies
license: MIT license: MIT
min_ansible_version: 1.9 min_ansible_version: 2.0
platforms: platforms:
- name: Debian - name: Debian
versions: versions:
...@@ -14,7 +14,7 @@ galaxy_info: ...@@ -14,7 +14,7 @@ galaxy_info:
versions: versions:
- precise - precise
- trusty - trusty
categories:
- database
dependencies: dependencies:
- role: common - src: https://www.shore.co.il/git/ansible-role-ca-store
scm: git
name: ca-store
---
ansible:
verbose: v
playbook: tests/playbook.yml
diff: True
molecule:
testinfra_dir: tests
ansible_config_template: ansible.cfg
vagrant:
providers:
- name: virtualbox
type: virtualbox
platforms:
- name: openbsd
box: kaorimatz/openbsd-5.9-amd64
instances:
- name: ansible-role-example
options:
append_platform_to_hostname: yes
raw_config_args:
- 'vm.synced_folder ".", "/vagrant", disabled: true'
- 'vbguest.auto_update = false'
- 'landrush.enabled = false'
- 'landrush_ip.override = false'
--- ---
# tasks file for ansible-mysql # tasks file for ansible-role-mysql
- assert:
that:
- ansible_os_family == 'OpenBSD'
- ansible_distribution_release == '5.9'
- name: apt install - name: apt install
apt: apt:
......
---
- hosts: all
gather_facts: false
roles:
- role: ansible-role-example
def test_example(Command):
assert Command('uname').rc == 0
def test_root(Command, Sudo):
with Sudo():
assert Command('whoami').stdout == 'root'
--- ---
# vars file for ansible-mysql # vars file for ansible-role-mysql
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment