From 315abee6e30a0a1f00b67d9ad4d0e1df64f42697 Mon Sep 17 00:00:00 2001 From: "Farhaan Bukhsh(fhackdroid)" Date: Fri, 3 Mar 2017 22:36:49 +0530 Subject: [PATCH] Improved Vagrantfile and added ansible provision This commit adds Vagrantfile and ansible to add provision to Vagrant image Signed-off-by: Farhaan Bukhsh(fhackdroid) --- Vagrantfile | 15 ++++++---- ansible/roles/ircb-dev/handlers/main.yml | 2 ++ ansible/roles/ircb-dev/tasks/main.yml | 35 ++++++++++++++++++++++++ ansible/vagrant-playbook.yml | 7 +++++ requirements.txt | 1 + 5 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 ansible/roles/ircb-dev/handlers/main.yml create mode 100644 ansible/roles/ircb-dev/tasks/main.yml create mode 100644 ansible/vagrant-playbook.yml diff --git a/Vagrantfile b/Vagrantfile index 5ea40b5..7be1c9c 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -23,6 +23,7 @@ Vagrant.configure("2") do |config| # within the machine from a port on the host machine. In the example below, # accessing "localhost:8080" will access port 80 on the guest machine. # config.vm.network "forwarded_port", guest: 80, host: 8080 + config.vm.network "forwarded_port", guest: 9000, host: 9000 # Create a private network, which allows host-only access to the machine # using a specific IP. @@ -47,13 +48,15 @@ Vagrant.configure("2") do |config| # the above mentioned line # config.vm.synced_folder ".", "/home/vagrant/devel", type: "sshfs", sshfs_opts_append: "-o nonempty", reverse: true # - # This config installs various system dependency for irc as required to run - # it - config.vm.provision "shell", inline: "sudo dnf -y install python3 python3-devel openssl openssl-devel redis" - config.vm.provision "shell", inline: "sudo pip3 install -r devel/requirements.txt" - config.vm.provision "shell", inline: "python3 setup.py develop" + # Comment this line if you would like to disable the automatic update during provisioning + config.vm.provision "shell", inline: "sudo dnf upgrade -y" + # bootstrap and run with ansible + config.vm.provision "shell", inline: "sudo dnf -y install python2-dnf libselinux-python" + config.vm.provision "ansible" do |ansible| + ansible.playbook = "ansible/vagrant-playbook.yml" + end + config.vm.provision "shell", inline: "cd /home/vagrant/devel && sudo python3 setup.py develop" config.vm.provision "shell", inline: "sudo systemctl start redis.service" - # Provider-specific configuration so you can fine-tune various # backing providers for Vagrant. These expose provider-specific options. # Example for VirtualBox: diff --git a/ansible/roles/ircb-dev/handlers/main.yml b/ansible/roles/ircb-dev/handlers/main.yml new file mode 100644 index 0000000..1203121 --- /dev/null +++ b/ansible/roles/ircb-dev/handlers/main.yml @@ -0,0 +1,2 @@ +- name: restart redis + service: name=redis state=restarted diff --git a/ansible/roles/ircb-dev/tasks/main.yml b/ansible/roles/ircb-dev/tasks/main.yml new file mode 100644 index 0000000..bdc17ad --- /dev/null +++ b/ansible/roles/ircb-dev/tasks/main.yml @@ -0,0 +1,35 @@ +--- +- name: Install helpfull packages + dnf: name={{ item }} state=present + with_items: + - git + - python-rpdb + - tmux + - tree + - vim-enhanced + +- name: Install ircb development packages + dnf: name={{ item }} state=present + with_items: + - gcc + - libffi-devel + - python-alembic + - redis + - python3-devel + - openssl-devel + - python-pip + - python-virtualenvwrapper + - python-devel + - libffi + - python + - zeromq + - zeromq-devel + - redhat-rpm-config + +- name: Install python packages for ircb + pip: requirements=/home/vagrant/devel/requirements.txt executable=pip3.5 + +- name: Run python3 setup + shell: python3 setup.py develop + args: + chdir: /home/vagrant/devel diff --git a/ansible/vagrant-playbook.yml b/ansible/vagrant-playbook.yml new file mode 100644 index 0000000..e9a7eaa --- /dev/null +++ b/ansible/vagrant-playbook.yml @@ -0,0 +1,7 @@ +--- +- hosts: all + become: true + become_method: sudo + vars: + roles: + - ircb-dev diff --git a/requirements.txt b/requirements.txt index b7f63b6..aad89ee 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,3 +15,4 @@ aiohttp-session[secure]==0.5.0 aiozmq==0.7.1 msgpack-python==0.4.7 PyYAML==3.11 +redis