"Fossies" - the Fresh Open Source Software Archive

Member "vagrant-2.2.14/plugins/provisioners/ansible/cap/guest/redhat/ansible_install.rb" (20 Nov 2020, 1757 Bytes) of package /linux/misc/vagrant-2.2.14.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 require_relative "../facts"
    2 require_relative "../pip/pip"
    3 
    4 module VagrantPlugins
    5   module Ansible
    6     module Cap
    7       module Guest
    8         module RedHat
    9           module AnsibleInstall
   10 
   11             def self.ansible_install(machine, install_mode, ansible_version, pip_args, pip_install_cmd = "")
   12               case install_mode
   13               when :pip
   14                 pip_setup machine, pip_install_cmd
   15                 Pip::pip_install machine, "ansible", ansible_version, pip_args, true
   16               when :pip_args_only
   17                 pip_setup machine, pip_install_cmd
   18                 Pip::pip_install machine, "", "", pip_args, false
   19               else
   20                 ansible_rpm_install machine
   21               end
   22             end
   23 
   24             private
   25 
   26             def self.ansible_rpm_install(machine)
   27               rpm_package_manager = Facts::rpm_package_manager(machine)
   28 
   29               epel = machine.communicate.execute "#{rpm_package_manager} repolist epel | grep -q epel", error_check: false
   30               if epel != 0
   31                 machine.communicate.sudo 'sudo rpm -i https://dl.fedoraproject.org/pub/epel/epel-release-latest-`rpm -E %dist | sed -n \'s/.*el\([0-9]\).*/\1/p\'`.noarch.rpm'
   32               end
   33               machine.communicate.sudo "#{rpm_package_manager} -y --enablerepo=epel install ansible"
   34             end
   35 
   36             def self.pip_setup(machine, pip_install_cmd = "")
   37               rpm_package_manager = Facts::rpm_package_manager(machine)
   38 
   39               machine.communicate.sudo("#{rpm_package_manager} -y install curl gcc libffi-devel openssl-devel python-crypto python-devel python-setuptools")
   40               Pip::get_pip machine, pip_install_cmd
   41             end
   42 
   43           end
   44         end
   45       end
   46     end
   47   end
   48 end