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 ffdfd
• 5,550 points
849 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,300 points

Related Questions In Ansible

0 votes
1 answer
0 votes
1 answer

How to create a key pair on AWS using Ansible-Playbook?

Hi@akhtar, You can find the ec2_key module in ...READ MORE

answered Aug 12, 2020 in Ansible by MD
• 95,460 points
1,452 views
+15 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,040 views
+2 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,300 points
2,583 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,300 points
5,594 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP