"Fossies" - the Fresh Open Source Software Archive

Member "vagrant-2.2.14/test/unit/plugins/provisioners/ansible/cap/guest/ubuntu/ansible_install_test.rb" (20 Nov 2020, 2790 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 "../../../../../../base"
    2 require_relative "../shared/pip_ansible_install_examples"
    3 
    4 
    5 require Vagrant.source_root.join("plugins/provisioners/ansible/cap/guest/ubuntu/ansible_install")
    6 
    7 
    8 describe VagrantPlugins::Ansible::Cap::Guest::Ubuntu::AnsibleInstall do
    9   include_context "unit"
   10 
   11   subject { VagrantPlugins::Ansible::Cap::Guest::Ubuntu::AnsibleInstall }
   12 
   13   let(:iso_env) do
   14     # We have to create a Vagrantfile so there is a root path
   15     env = isolated_environment
   16     env.vagrantfile("")
   17     env.create_vagrant_env
   18   end
   19 
   20   let(:machine) { iso_env.machine(iso_env.machine_names[0], :dummy) }
   21   let(:communicator) { double("comm") }
   22 
   23   before do
   24     allow(machine).to receive(:communicate).and_return(communicator)
   25     allow(communicator).to receive(:execute).and_return(true)
   26   end
   27 
   28   describe "#ansible_install" do
   29 
   30     it_behaves_like "Ansible setup via pip on Debian-based systems"
   31 
   32     describe "when install_mode is :default (or unknown)" do
   33       describe "#ansible_apt_install" do
   34         describe "installs ansible from ansible/ansible PPA repository" do
   35 
   36           check_if_add_apt_repository_is_present="test -x \"$(which add-apt-repository)\""
   37 
   38           it "first installs 'software-properties-common' package if add-apt-repository is not already present" do
   39             allow(communicator).to receive(:test).
   40               with(check_if_add_apt_repository_is_present).and_return(false)
   41 
   42             expect(communicator).to receive(:sudo).once.ordered.
   43               with("""
   44                   apt-get update -y -qq && \
   45                   DEBIAN_FRONTEND=noninteractive apt-get install -y -qq software-properties-common --option \"Dpkg::Options::=--force-confold\"
   46                 """)
   47             expect(communicator).to receive(:sudo).once.ordered.
   48               with("""
   49                 add-apt-repository ppa:ansible/ansible -y && \
   50                 apt-get update -y -qq && \
   51                 DEBIAN_FRONTEND=noninteractive apt-get install -y -qq ansible --option \"Dpkg::Options::=--force-confold\"
   52               """)
   53 
   54             subject.ansible_install(machine, :default, "", "", "")
   55           end
   56 
   57           it "adds 'ppa:ansible/ansible' and install 'ansible' package" do
   58             allow(communicator).to receive(:test).
   59               with(check_if_add_apt_repository_is_present).and_return(true)
   60 
   61             expect(communicator).to receive(:sudo).
   62               with("""
   63                 add-apt-repository ppa:ansible/ansible -y && \
   64                 apt-get update -y -qq && \
   65                 DEBIAN_FRONTEND=noninteractive apt-get install -y -qq ansible --option \"Dpkg::Options::=--force-confold\"
   66               """)
   67 
   68             subject.ansible_install(machine, :default, "", "", "")
   69           end
   70 
   71         end
   72       end
   73     end
   74   end
   75 
   76 end