Search code examples
ansibleelmansible-role

tell Ansible to elm init


I have a ansible role for elm setup, and the last task is elm init, to configure initial elm project, but I'm having problem with this task because I need to tell yes when elm prompt me

Hello! Elm projects always start with an elm.json file. I can create them!

Now you may be wondering, what will be in this file? How do I add Elm files to my project? How do I see it in the browser? How will my code grow? Do I need more directories? What about tests? Etc.

Check out https://elm-lang.org/0.19.0/init for all the answers!

Knowing all that, would you like me to create an elm.json file now? [Y/n]: y

Ansible does not understand this, so how can I tell Ansible to say Y?

Ansible task is:

- name: setup elm project
  shell: elm init path="{{ project_path }}"
  tags:
    - configuration

Solution

  • The standard way to do this in a unix shell is to pipe yes to the command, which will send it a y every time it asks. And since ansible will take any shell command, this should work on any Unix/Linux/macOS machine:

    shell: yes | elm init path="{{ project_path }}"