From b18fa2d2282852cbcb23352418e4a417631c8387 Mon Sep 17 00:00:00 2001 From: Thibaud Fabre Date: Tue, 27 Sep 2016 10:08:42 +0200 Subject: [PATCH] PHRAS-1214 Allow debugger access to Vagrant host IP addresses --- Vagrantfile | 10 ++++++---- resources/ansible/roles/app/tasks/main.yml | 6 ++++++ resources/ansible/roles/elasticsearch/tasks/main.yml | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index d0e96206eb..84884aceed 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -26,12 +26,10 @@ def config_net(config) "dev." + $hostname + ".vb" ] - #config.vm.network :public_network, type: "dhcp", bridge: "en0: Ethernet" - # Assign static IP if present in network config if File.file?($root + "/.network.conf") ipAddress = File.read($root + "/.network.conf") - config.vm.network :private_network, ip: ipAddress + #config.vm.network :private_network, ip: ipAddress else # vboxnet0 can be changed to use a specific private_network config.vm.network :private_network, type: "dhcp" @@ -48,6 +46,7 @@ end # By default, the name of the VM is the project's directory name $hostname = File.basename($root).downcase +$hostIps = `ip addr show | grep inet | grep -v inet6 | cut -d' ' -f6 | cut -d'/' -f1`.split("\n"); Vagrant.configure("2") do |config| @@ -80,9 +79,10 @@ Vagrant.configure("2") do |config| config.vm.provision "ansible" do |ansible| ansible.playbook = "resources/ansible/playbook.yml" ansible.limit = 'all' - ansible.verbose = 'v' + ansible.verbose = 'vvv' ansible.extra_vars = { hostname: $hostname, + host_addresses: $hostIps, postfix: { postfix_domain: $hostname + ".vb" } @@ -92,7 +92,9 @@ Vagrant.configure("2") do |config| config.vm.provision "ansible", run: "always" do |ansible| ansible.playbook = "resources/ansible/playbook-always.yml" ansible.limit = 'all' + ansible.verbose = 'vvv' ansible.extra_vars = { + host_addresses: $hostIps, hostname: $hostname } end diff --git a/resources/ansible/roles/app/tasks/main.yml b/resources/ansible/roles/app/tasks/main.yml index 35b52bc1b9..f9271980a3 100644 --- a/resources/ansible/roles/app/tasks/main.yml +++ b/resources/ansible/roles/app/tasks/main.yml @@ -35,3 +35,9 @@ shell: 'bin/setup system:install --email=admin@{{ hostname }}.vb --password=admin --db-host=127.0.0.1 --db-port=3306 --db-user={{ mariadb.user }} --db-password={{ mariadb.password }} --db-template=fr --appbox={{ mariadb.database }} --databox={{ mariadb.databox_db }} --server-name=www.{{ hostname }}.vb --data-path=/vagrant/datas -y' args: chdir: /vagrant/ + +- name: Enable debugger for host IP addresses + shell: bin/setup system:config add debugger.allowed-ips "{{ item}}" + with_items: '{{ host_addresses }}' + args: + chdir: /vagrant/ diff --git a/resources/ansible/roles/elasticsearch/tasks/main.yml b/resources/ansible/roles/elasticsearch/tasks/main.yml index aef25e0260..5608d8f9f9 100644 --- a/resources/ansible/roles/elasticsearch/tasks/main.yml +++ b/resources/ansible/roles/elasticsearch/tasks/main.yml @@ -17,13 +17,17 @@ - name: Install Dependencies apt: pkg=oracle-java8-installer state=latest -- name: Download +- name: Remove temporary debian package + shell: rm -f /tmp/elasticsearch-{{ elasticsearch.version }}.deb + when: not is_installed + +- name: Download debian package get_url: > url={{ elasticsearch_url }} dest=/tmp/elasticsearch-{{ elasticsearch.version }}.deb when: not is_installed -- name: Install +- name: Install debian package apt: deb=/tmp/elasticsearch-{{ elasticsearch.version }}.deb when: not is_installed