commit fbd792baf653b527e585024f6008a27da444a006 Author: Robert de Bock Date: Thu Jan 3 11:17:38 2019 +0000 Initial commit. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..12bf155 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +id_rsa +roles/* diff --git a/README.md b/README.md new file mode 100644 index 0000000..64e6367 --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +# Ansible development environment + +Setup a machine to write Ansible roles. Includes: +- [ansible](https://github.com/ansible) +- [ansible-lint](https://github.com/ansible/ansible-lint) +- [molecule](https://molecule.readthedocs.io/en/latest/) +- [travis (cli)](https://github.com/travis-ci/travis.rb) +- [ara](https://github.com/openstack/ara) + +## Download + +In some directory, maybe `Documents` run: + +```sh +git clone https://github.com/robertdebock/ansible-development-environment +cd ansible-development-environment +``` + +## Setup + +Download all required roles: + +```sh +ansible-galaxy install --role-file roles/requirements.yml +``` + +Now change a few files: + +- `files/gitconfig` should contain your details. +- `files/id_rsa` should contain an ssh-key used to commit to GitHub. +- `inventory/hosts` should contain your machine. +- `inventory/group_vars/all.yml` should contain your details. + +## Install + +Simply run `./playbook.yml`. Preparing your system will take about 15 minutes or so. + +## Code + +You are now ready to code! Have fun using these commands: + +```sh +# See if your code meets all rules. +ansible-lint . +# Test all scenarios. +molecule test +# Test a specific scenario. +molecule test --scenario-name fedora-latest +``` + +You can see the playbook runs on https://localhost:9191/ diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..41e8b33 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,4 @@ +[defaults] +roles_path=roles +retry_files_enabled=no +inventory=inventory diff --git a/files/gitconfig b/files/gitconfig new file mode 100644 index 0000000..19289fd --- /dev/null +++ b/files/gitconfig @@ -0,0 +1,3 @@ +[user] + email = robert@meinit.nl + name = Robert de Bock diff --git a/inventory/group_vars/all.yml b/inventory/group_vars/all.yml new file mode 100644 index 0000000..e8ae24a --- /dev/null +++ b/inventory/group_vars/all.yml @@ -0,0 +1,107 @@ +--- +bootstrap_wait_for_host: yes + +users_group_list: + - name: robertdb + +users_user_list: + - name: robertdb + comment: Robert de Bock + group: robertdb + groups: wheel + cron_allow: yes + sudo_options: "ALL=(ALL) NOPASSWD: ALL" + password: "$1$QbmM32Kz$nzFTRRxti0ZZ2oSC6ii8p1" + authorized_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCWswOogkZz/ihQA0lENCwDwSzmtmBWtFwzIzDlfa+eb4rBt6rZBg7enKeMqYtStI/NDneBwZUFBDIMu5zJTbvg7A60/WDhWXZmU21tZnm8K7KREFYOUndc6h//QHig6IIaIwwBZHF1NgXLtZ0qrUUlNU5JSEhDJsObMlPHtE4vFP8twPnfc7hxAnYma5+knU6qTMCDvhBE5tGJdor4UGeAhu+SwSVDloYtt1vGTmnFn8M/OD/fRMksusPefxyshJ37jpB4jY/Z9vzaNHwcj33prwl1b/xRfxr/+KRJsyq+ZKs9u2TVw9g4p+XLdfDtzZ8thR2P3x3MFrZOdFmCbo/5" + +repository_base: "ssh://git@github.com/robertdebock" +repository_destination: /home/robertdb/github.com/robertdebock + +repositories: + - ansible-role-ansible + - ansible-role-ansible_lint + - ansible-role-apt_autostart + - ansible-role-ara + - ansible-role-artifactory + - ansible-role-at + - ansible-role-awx + - ansible-role-backup + - ansible-role-bootstrap + - ansible-role-buildtools + - ansible-role-ca + - ansible-role-cargo + - ansible-role-clamav + - ansible-role-cloud9 + - ansible-role-cntlm + - ansible-role-common + - ansible-role-cve_2018_19788 + - ansible-role-dhcpd + - ansible-role-digitalocean-agent + - ansible-role-dns + - ansible-role-docker + - ansible-role-dovecot + - ansible-role-epel + - ansible-role-fail2ban + - ansible-role-firewall + - ansible-role-git + - ansible-role-glusterfs + - ansible-role-go + - ansible-role-gotop + - ansible-role-haproxy + - ansible-role-haveged + - ansible-role-httpd + - ansible-role-investigate + - ansible-role-irslackd + - ansible-role-java + - ansible-role-jenkins + - ansible-role-lynis + - ansible-role-mediawiki + - ansible-role-memcached + - ansible-role-mitogen + - ansible-role-molecule + - ansible-role-mssql + - ansible-role-mysql + - ansible-role-natrouter + - ansible-role-nginx + - ansible-role-npm + - ansible-role-ntp + - ansible-role-openssh + - ansible-role-openvas + - ansible-role-owncloud + - ansible-role-packer + - ansible-role-php + - ansible-role-phpmyadmin + - ansible-role-postfix + - ansible-role-python-pip + - ansible-role-reboot + - ansible-role-redis + - ansible-role-release + - ansible-role-restore + - ansible-role-revealmd + - ansible-role-roundcubemail + - ansible-role-rsyslog + - ansible-role-ruby + - ansible-role-rundeck + - ansible-role-scl + - ansible-role-selinux + - ansible-role-skeleton + - ansible-role-snort + - ansible-role-spamassassin + - ansible-role-squid + - ansible-role-sudo-pair + - ansible-role-terraform + - ansible-role-tftpd + - ansible-role-tomcat + - ansible-role-travis + - ansible-role-update + - ansible-role-users + - ansible-role-xinetd + - ansible-role-zabbix + - ansible-role-zabbix_agent + - ansible-role-zabbix_proxy + - ansible-role-zabbix_repository + - ansible-role-zabbix_server + - ansible-role-zabbix_web + - ansible-tools + - drawings + - robertdebock.github.io diff --git a/inventory/hosts b/inventory/hosts new file mode 100644 index 0000000..bd4026e --- /dev/null +++ b/inventory/hosts @@ -0,0 +1 @@ +fedora-s-1vcpu-2gb-ams3-01 ansible_host=167.99.46.114 diff --git a/playbook.yml b/playbook.yml new file mode 100755 index 0000000..626b55b --- /dev/null +++ b/playbook.yml @@ -0,0 +1,55 @@ +#!/usr/bin/env ansible-playbook +--- +- name: setup an ansible development environment + hosts: all + become: yes + gather_facts: no + + roles: + - robertdebock.bootstrap + - robertdebock.update + - robertdebock.fail2ban + - robertdebock.openssh + - robertdebock.digitalocean_agent + - robertdebock.common + - robertdebock.users + - robertdebock.postfix + - robertdebock.docker + - robertdebock.investigate + - robertdebock.ansible + - robertdebock.ansible_lint + - robertdebock.buildtools + - robertdebock.molecule + - robertdebock.ara + - robertdebock.ruby + - robertdebock.travis + + tasks: + - name: copy private key + copy: + src: id_rsa + dest: /home/robertdb/.ssh/id_rsa + mode: "0400" + owner: robertdb + group: robertdb + + - name: copy git configuration + copy: + src: gitconfig + dest: /home/robertdb/.gitconfig + + - name: create repository_destination + file: + path: "{{ repository_destination }}" + state: directory + owner: robertdb + group: robertdb + + - name: clone all roles + git: + repo: "{{ repository_base }}/{{ item }}.git" + dest: "{{ repository_destination }}/{{ item }}" + accept_hostkey: yes + key_file: /home/robertdb/.ssh/id_rsa + with_items: "{{ repositories }}" + become_user: robertdb