Install Cordova on mac machine using Ansible

76 views
Skip to first unread message

resud...@corelogic.com

unread,
Apr 17, 2017, 3:05:38 PM4/17/17
to Ansible Project
Hello Everyone,

i'm trying to setup one of my mac machine using ansible playbook and i want to install cordova as part of dependencies. i have wrote a playbook and even tried to call some roles which are available in ansible-galaxy. but for all of them i'm getting the below error. please let me know where i'm doing wrong. 

Thanks in advance. 


Error: 
TASK [martinmicunda.ionic : Install Cordova] ***************************************************************************************************************************
fatal: [**]: FAILED! => {"changed": false, "failed": true, "msg": "Failed to find required executable npm in paths: /Users/builder/.fastlane/bin:/apps/groovy/bin:/Users/builder/perl5/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin"}

My Playbook: 
---
- hosts: all
  sudo: yes
  roles:
    - martinmicunda.ionic
    - martinmicunda.nodejs
  vars:

     applications:
      - firefox
      - google-chrome
      - skype
      - sublime-text3

     install_oh_my_zsh:  true

     brew_taps:
      - caskroom/cask
      - caskroom/versions
      - homebrew/binary
      - homebrew/dupes
      - homebrew/versions

     brew_utils:

      - autoconf
      - android-sdk
      - autojump
      - bash
      - boot2docker
      - brew-cask
      - cowsay
      - coreutils
      - findutils
      - git
      - go
      - gpg
      - node
      - npm
      - openssl
      - python
      - rsync
      - ruby-build
 - openssl
      - python
      - rsync
      - ruby-build
      - vim
      - wget
      - zsh
      - tree

zsh_path: /usr/local/bin/zsh

home: "{{ lookup('env','HOME') }}"


  tasks:
  
      - name: Install "cordova"  node.js package on latest version
       npm:
        name: cordova
        state: latest
  - name: Check Homebrew is installed

        stat: path=/usr/local/bin/brew
        register: brew_installed

      - name: Install Homebrew
        shell: ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"


      - name: Instal required Homebrew Taps
        shell: brew tap {{ item }}
        with_items: brew_taps

      - name: Check homebrew-cask is installed
        stat: path=/usr/local/bin/brew-cask.rb
        register: brew_cask_installed

      - name: Install homebrew-cask
        shell: brew install brew-cask
        when: brew_cask_installed.stat.exists == false

     # - name: Install Cordova
       # npm:
        #executable: "~/.local/bin/npm"
         # name=cordova
          #state=present
          #global=yes
          #version=6.5.0
          #become: yes
          #become_user: builder
### UTILS

      - name: Install libraries/utils with homebrew
        homebrew: name={{ item }} state=present
        with_items: brew_utils

      - name: Cleanup after brewing
        shell: brew cleanup


    ### APPZ

      - name: Check for installed apps(casks)
        shell: brew cask list | grep {{ item }}
        register: installed_applications
        with_items: applications
        ignore_errors: true

      - name: Install Apps with brew-cask
 shell: brew cask install {{ item }}
        with_items: applications
        when: "{{ item not in installed_applications.results|map(attribute='stdout') }}"

    # Caveats: megasync only works if called from /Applications
      - name: Linking MEGASync with brew-cask
        shell: ln -s '/opt/homebrew-cask/Caskroom/megasync/latest/MEGAsync.app' '/Applications/MEGAsync.app'
        when: "'megasync' in applications"
        ignore_errors: true # hacky


    ### ZSH radness

      - name: Determine if zsh is default/current shell
        shell: echo $SHELL
        register: current_shell

      - name: Enable zsh in /etc/shells
        shell: sudo /bin/sh -c 'grep -q "{{ zsh_path }}" /etc/shells || echo "{{ zsh_path }}" >> /etc/shells'
        when: current_shell.stdout != '/usr/local/bin/zsh'
      #" unbreak my syntax highlighting...

      - name: Set zsh as default shell
        shell: chsh -s {{ zsh_path }}
        when: current_shell.stdout != '/usr/local/bin/zsh'
        sudo: true

      - name: Use GNU tools instead of osx counterparts (grep find etc)
        shell: echo 'export PATH=$(brew --prefix coreutils)/libexec/gnubin:$PATH' >> ~/.zshrc


      - name: Install oh-my-zsh
        git: repo=https://github.com/robbyrussell/oh-my-zsh dest=~/.oh-my-zsh
        sudo: false
        when: install_oh_my_zsh == true
        tags: install_oh_my_zsh



Reply all
Reply to author
Forward
0 new messages