diff --git a/.gitignore b/.gitignore index eb9b1f62f4139a3d76acdc34227f910ab5bad6c4..e1cf205905d93c46016f27f9e4df6a1da11cfd86 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,11 @@ +*.sw[po] ~* *~ -*.swp -*.swo +.DS_Store +__pycache__ +*.py[cod] +.cache/ +.molecule/ +.vagrant/ +*.log +*.retry diff --git a/.molecule/roles/.gitkeep b/.molecule/roles/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c7e92e9767780286be6975fb5dbfae7dd32e2a42..6274aa01b223aa43f1be946e2da2470f5d90e446 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,8 +1,12 @@ -- repo: git://github.com/pre-commit/pre-commit-hooks - sha: cf550fcab3f12015f8676b8278b30e1a5bc10e70 +- repo: https://github.com/pre-commit/pre-commit-hooks + sha: 6dfcb89af3c9b4d172cc2e5a8a2fa0f54615a338 hooks: - id: check-added-large-files - id: check-json - id: check-xml - id: check-yaml - id: check-merge-conflict +- repo: https://www.shore.co.il/git/ansible-pre-commit/ + sha: 94b506c144d4e22ebc1deef637a818db13bcaca5 + hooks: + - id: ansible-pre-commit diff --git a/LICENSE.txt b/LICENSE.txt index 38c6bf23b1163a62b464155a95401d90348e3ff3..ee4c95e0b73a3681aa80f3de24fba84d3d1ed71a 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ 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 of this software and associated documentation files (the "Software"), to deal diff --git a/README.rst b/README.rst index 17b98f85a955442c0ecda8230fefa1d24f3abca8..372b9c54d38338f39be8e4934c45c3a22a52eaab 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,5 @@ -ansible-mysql -############# +MySQL +##### An Ansible role to install and configure a MySQL server. The role creates an 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 ------------ -Debian Wheezy or later (Ubuntu Precise or later should probably work, but it's -untested). +See :code:`meta/main.yml` and assertions at top of :code:`tasks/main.yml`. Role Variables -------------- -:: - mysql_admin_password: #The password for the admin account. +See :code:`defaults/main.yml`. Dependencies ------------ -`Common role <https://www.shore.co.il/cgit/ansible-common/>`_ +See :code:`meta/main.yml`. Example Playbook ---------------- -:: - - hosts: servers - roles: - - role: mysql - mysql_admin_password: qwerty123 +See :code:`tests/playbook.yml`. -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 - scm: git - path: roles/ - name: common +To run the full test suite: - - src: https://www.shore.co.il/cgit/ansible-mysql - scm: git - path: roles/ - name: mysql +.. code:: shell + + molecule test 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 ------------------ @@ -55,12 +51,4 @@ Author Information Nimrod Adar, `contact me <nimrod@shore.co.il>`_ or visit my `website <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 -at: https://www.shore.co.il/cgit/. - -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. +at: https://www.shore.co.il/git/. diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000000000000000000000000000000000000..10b3da5cfa1edbc2186229872bd129f0e34222c8 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,6 @@ +[defaults] +host_key_checking = False +retry_files_enabled = False +roles_path = roles:../:../../:.molecule/roles +command_warnings = True +deprecation_warnings = True diff --git a/defaults/main.yml b/defaults/main.yml index 405745f6b9fa1cb430f7fa2f1e063d80d8e7c20b..b2fc2dc85f1f1f7ac04259d2859ac48368b86de6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,4 +1,4 @@ --- -# defaults file for ansible-mysql +# defaults file for ansible-role-mysql mysql_admin_password: diff --git a/files/.gitkeep b/files/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/handlers/main.yml b/handlers/main.yml index e10199486aee7c00c9bad28f461c23b414fe92cf..ce3fe1e8f898121475e2e82cce0be29bedc6387f 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,5 +1,5 @@ --- -# handlers file for ansible-mysql +# handlers file for ansible-role-mysql - name: Restart MySQL service: diff --git a/meta/main.yml b/meta/main.yml index 96d80dabf6f82538774e95919cf457e1e719a637..4ac93e8c09db384b2c1b3b1b54c322fed6237068 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -4,7 +4,7 @@ galaxy_info: description: MySQL role. For more information read the README file. company: Shore technologies license: MIT - min_ansible_version: 1.9 + min_ansible_version: 2.0 platforms: - name: Debian versions: @@ -14,7 +14,7 @@ galaxy_info: versions: - precise - trusty - categories: - - database dependencies: -- role: common + - src: https://www.shore.co.il/git/ansible-role-ca-store + scm: git + name: ca-store diff --git a/molecule.yml b/molecule.yml new file mode 100644 index 0000000000000000000000000000000000000000..0e6fa4796099a5c1be84f0bdaa1420fb298a35bc --- /dev/null +++ b/molecule.yml @@ -0,0 +1,26 @@ +--- +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' diff --git a/tasks/main.yml b/tasks/main.yml index 85a3ca83e51172adbb40e5fccd1d8a7a938c5fd1..74b974251db44cc767e4e862740db7cb05c0ff35 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,5 +1,9 @@ --- -# 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 apt: diff --git a/templates/.gitkeep b/templates/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/playbook.yml b/tests/playbook.yml new file mode 100644 index 0000000000000000000000000000000000000000..e739a2b8827a164702a059f09277dd60fa516e36 --- /dev/null +++ b/tests/playbook.yml @@ -0,0 +1,5 @@ +--- +- hosts: all + gather_facts: false + roles: + - role: ansible-role-example diff --git a/tests/test_example.py b/tests/test_example.py new file mode 100644 index 0000000000000000000000000000000000000000..a38c7bad4a16b5cd6a5e071ede073a10c7694154 --- /dev/null +++ b/tests/test_example.py @@ -0,0 +1,6 @@ +def test_example(Command): + assert Command('uname').rc == 0 + +def test_root(Command, Sudo): + with Sudo(): + assert Command('whoami').stdout == 'root' diff --git a/vars/main.yml b/vars/main.yml index f47764f263e607610d69a9a7c763ea8949451de5..5ec007db8ee77330c49b3f045a3edb72c683896e 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,2 +1,2 @@ --- -# vars file for ansible-mysql +# vars file for ansible-role-mysql