unable to build grails war on a vagrant machine using ansible

0 votes

I am trying to configure a vagrant machine to deploy a grails war file onto tomcat 7. This error comes up when I try and run the playbook:

TASK [Build application] ******************************************************* fatal: [vagrant]: FAILED! => {"changed": true, "cmd": ["sh", "/home/vagrant/src/grailsw", "war"], "delta": "0:00:00.110227", "end": "2017-03-23 12:12:07.728096", "failed": true, "rc": 1, "start": "2017-03-23 12:12:07.617869", "stderr": "Error: Could not find or load main class org.grails.wrapper.GrailsWrapper", "stdout": "", "stdout_lines": [], "warnings": []} to retry, use: --limit @/home/user/work/scratch/vagrant/petclinic_ansible/playbook.retry

If I try and create the war file by sshing into the machine, it is created, but I can't create it using ansible. This si my vagrant file:

Vagrant.configure("2") do |config|

  config.vm.define "vagrant" do |config|
      config.vm.box = "bento/ubuntu-16.04"
      config.vm.network :private_network, ip: "192.168.10.10"

      config.vm.provision "ansible" do  |ansible|
          ansible.playbook = "playbook.yml"
      end
  end

  config.vm.provider  "virtualbox" do  |vb|
      vb.memory = "1024"
      vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
  end
 end

playbook.yml

- hosts: all
become: true

  roles:
      - java
      - servers

tasks:
    - name: Make sure src directory doesn't exist
      file:
        path: /home/vagrant/src
        state: absent
        force: yes

    - name: Pull repository
      git:
        repo: https://github.com/Rcsuax/grails-petclinic.git
        dest: /home/vagrant/src
        version: master

    - name: Build application
      become: true
      command: ./home/vagrant/src/grailsw war
Jul 2, 2018 in Ansible by Atul
• 5,530 points
56 views

1 answer to this question.

0 votes

Try and run the command using shell module instead of command. hopefully it works for you.

  - name: Build application
    become: true
    shell: ./grailsw war
    args:
      chdir: src/
      creates: target/petclinic-0.2.war
    environment:
        JAVA_HOME: /usr/lib/jvm/java-8-oracle
answered Jul 2, 2018 by ajs3033
• 7,280 points

Related Questions In Ansible

0 votes
1 answer
0 votes
3 answers
0 votes
1 answer

Running ansible command on a single server when it is deployed to multiple servers

You can try the run_once attribute: Example from ...READ MORE

answered Jun 13, 2018 in Ansible by DareDev
• 6,810 points
150 views
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
124 views
0 votes
1 answer
0 votes
1 answer

Getting numbered build artefact using ansible from jenkins

You can get the build number with ...READ MORE

answered Aug 20, 2018 in Ansible by ajs3033
• 7,280 points
592 views
0 votes
1 answer

When conditional not working in Ansible

Your identation is wrong and when is ...READ MORE

answered Apr 27, 2018 in Ansible by ajs3033
• 7,280 points
647 views