How to use Vagrant provisioning to install a package without download?

Clash Royale CLAN TAG#URR8PPP
I'm using Vagrant boxes for several purposes, and in most cases the prepared boxes I can download are totally sufficient. However, sometimes I need one or a few additional packages installed on the box—for regular activities, not one-time use.
For example, I have a Vagrant box on my Mac (Linux guest on Mac host) which I primarily want for easy access to built-in Linux documentation (man pages, info pages, etc.) However, the box I am using doesn't have the man package installed when I first vagrant up.
If I just install the package manually, it will only last until the next vagrant destroy. If I use vagrant halt instead, I'll build up cruft on my system, which defeats the purpose of using vagrant as opposed to simply a Virtual Box.
I know the general answer to this is vagrant provisioning, and it could be as simple as a script with a single command sudo yum install man. (Although actually I don't even know specifically how to do that.) However, rather than downloading the man package and all dependencies each time I start the vagrant box, I would rather download those packages once, store them on my host system, and load them into the vm each time I vagrant up.
I have already run sudo yum install man --downloadonly on the guest, to get the packages I need, and sudo cp -r /var/cache/yum/x86_64/6/base/packages/ /vagrant/ to put the package files on my host.
So my question is really twofold:
What is the vagrant provisioning syntax to use for: (a) calling a script (to be stored in the same directory as the Vagrantfile), or (b) if possible, embedding a single command in the Vagrantfile (such as
sudo yum install man)?How can I give
yumthe option flags needed to install a package from a local directory (/vagrant) and to install any needed dependencies from that same local directory rather than from an online repository?
linux yum virtual-machine vagrant
add a comment |
I'm using Vagrant boxes for several purposes, and in most cases the prepared boxes I can download are totally sufficient. However, sometimes I need one or a few additional packages installed on the box—for regular activities, not one-time use.
For example, I have a Vagrant box on my Mac (Linux guest on Mac host) which I primarily want for easy access to built-in Linux documentation (man pages, info pages, etc.) However, the box I am using doesn't have the man package installed when I first vagrant up.
If I just install the package manually, it will only last until the next vagrant destroy. If I use vagrant halt instead, I'll build up cruft on my system, which defeats the purpose of using vagrant as opposed to simply a Virtual Box.
I know the general answer to this is vagrant provisioning, and it could be as simple as a script with a single command sudo yum install man. (Although actually I don't even know specifically how to do that.) However, rather than downloading the man package and all dependencies each time I start the vagrant box, I would rather download those packages once, store them on my host system, and load them into the vm each time I vagrant up.
I have already run sudo yum install man --downloadonly on the guest, to get the packages I need, and sudo cp -r /var/cache/yum/x86_64/6/base/packages/ /vagrant/ to put the package files on my host.
So my question is really twofold:
What is the vagrant provisioning syntax to use for: (a) calling a script (to be stored in the same directory as the Vagrantfile), or (b) if possible, embedding a single command in the Vagrantfile (such as
sudo yum install man)?How can I give
yumthe option flags needed to install a package from a local directory (/vagrant) and to install any needed dependencies from that same local directory rather than from an online repository?
linux yum virtual-machine vagrant
add a comment |
I'm using Vagrant boxes for several purposes, and in most cases the prepared boxes I can download are totally sufficient. However, sometimes I need one or a few additional packages installed on the box—for regular activities, not one-time use.
For example, I have a Vagrant box on my Mac (Linux guest on Mac host) which I primarily want for easy access to built-in Linux documentation (man pages, info pages, etc.) However, the box I am using doesn't have the man package installed when I first vagrant up.
If I just install the package manually, it will only last until the next vagrant destroy. If I use vagrant halt instead, I'll build up cruft on my system, which defeats the purpose of using vagrant as opposed to simply a Virtual Box.
I know the general answer to this is vagrant provisioning, and it could be as simple as a script with a single command sudo yum install man. (Although actually I don't even know specifically how to do that.) However, rather than downloading the man package and all dependencies each time I start the vagrant box, I would rather download those packages once, store them on my host system, and load them into the vm each time I vagrant up.
I have already run sudo yum install man --downloadonly on the guest, to get the packages I need, and sudo cp -r /var/cache/yum/x86_64/6/base/packages/ /vagrant/ to put the package files on my host.
So my question is really twofold:
What is the vagrant provisioning syntax to use for: (a) calling a script (to be stored in the same directory as the Vagrantfile), or (b) if possible, embedding a single command in the Vagrantfile (such as
sudo yum install man)?How can I give
yumthe option flags needed to install a package from a local directory (/vagrant) and to install any needed dependencies from that same local directory rather than from an online repository?
linux yum virtual-machine vagrant
I'm using Vagrant boxes for several purposes, and in most cases the prepared boxes I can download are totally sufficient. However, sometimes I need one or a few additional packages installed on the box—for regular activities, not one-time use.
For example, I have a Vagrant box on my Mac (Linux guest on Mac host) which I primarily want for easy access to built-in Linux documentation (man pages, info pages, etc.) However, the box I am using doesn't have the man package installed when I first vagrant up.
If I just install the package manually, it will only last until the next vagrant destroy. If I use vagrant halt instead, I'll build up cruft on my system, which defeats the purpose of using vagrant as opposed to simply a Virtual Box.
I know the general answer to this is vagrant provisioning, and it could be as simple as a script with a single command sudo yum install man. (Although actually I don't even know specifically how to do that.) However, rather than downloading the man package and all dependencies each time I start the vagrant box, I would rather download those packages once, store them on my host system, and load them into the vm each time I vagrant up.
I have already run sudo yum install man --downloadonly on the guest, to get the packages I need, and sudo cp -r /var/cache/yum/x86_64/6/base/packages/ /vagrant/ to put the package files on my host.
So my question is really twofold:
What is the vagrant provisioning syntax to use for: (a) calling a script (to be stored in the same directory as the Vagrantfile), or (b) if possible, embedding a single command in the Vagrantfile (such as
sudo yum install man)?How can I give
yumthe option flags needed to install a package from a local directory (/vagrant) and to install any needed dependencies from that same local directory rather than from an online repository?
linux yum virtual-machine vagrant
linux yum virtual-machine vagrant
edited Feb 10 at 19:09
Rui F Ribeiro
41.1k1479137
41.1k1479137
asked Oct 8 '15 at 18:44
WildcardWildcard
22.9k1065169
22.9k1065169
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
For example, I have a Vagrant box on my Mac (Linux guest on Mac host)
It would be interesting to know which distribution this is... Given that you're trying to use yum I imagine this is some RH/CentOS/.. stuff?
which I primarily want for easy access to built-in Linux documentation (man pages, info pages, etc.) However, the box I am using doesn't have the man package installed when I first vagrant up.
I don't know any distribution that doesn't install manby default.
If I were you, I'd use one of the official boxes on ATLAS, Debian comes to mind: https://vagrantcloud.com/debian/
Reply to Q1
Add this to your vagrantfile:
$script = <<SCRIPT
echo I am provisioning...
date > /etc/vagrant_provisioned_at
SCRIPT
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: $script
end
Example taken from
http://docs.vagrantup.com/v2/provisioning/shell.html#inline-scripts
This would execute the script at the top, resulting in the creation of /etc/vagrant_provisioned_at
Further adapted to your question:
$script = <<SCRIPT
yum install man
SCRIPT
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: $script
end
The provisioning script is run as UID0, so no need for sudo.
Reply to Q2
I'm a Debian user and as such RedHat illiterate ;-)
IMHO this would be rpm -hiv <filename>(i =install, h = hashmarks, v = verbose).
Related manpage
Perfect! Yes, I'm using CentOS; the vm box is "bento/centos-6.7" and it doesn't come with man. (Which is an odd setup; my physical CentOS install does.)rpmisn't smart enough to handle dependencies and just exits with an error if given the single file, BUT it is smart enough to put a list of filename arguments in dependency sequence. Since I already downloaded the dependencies as described in my question, I just usedrpm -i /vagrant/packages/*and it puts them in order and installs them all! (No need for -hv as it's just run during provisioning.)
– Wildcard
Oct 9 '15 at 13:08
1
I found the puppetlabs base boxes quite "vanilla", try one of those: atlas.hashicorp.com/puppetlabs They have a good naming scheme btw...
– Jan
Oct 9 '15 at 13:14
Aha! Even better; I've just switched over. Thanks! Still great to have the provisioning data/know-how; I will use that for my own setup and package installs in the future (rather than stuff likemanwhich should already be there....)
– Wildcard
Oct 9 '15 at 13:28
add a comment |
I just encountered this use case again; I will make a succinct record here of how I handled it.
I wanted to download (but not install) Git and PostgreSQL, and then install them during the vagrant provision process.
I used the following command from a fresh VM to download the packages with all dependencies (after sudo mkdir /vagrant/packages):
sudo yumdownloader --destdir=/vagrant/packages/ --resolve -y git postgresql
The trick with this command is, it downloads way too much. The next step was to establish the RPMs that I actually needed for the install. I did this by attempting:
sudo yum install /vagrant/packages/git-1.7.1-4.el6_7.1.x86_64.rpm /vagrant/packages/postgresql-8.4.20-6.el6.x86_64.rpm
And pressing "No" at the confirmation prompt because I could see it was planning to download dependencies. I took the listed dependencies and added them to my command:
sudo yum install /vagrant/packages/git-1.7.1-4.el6_7.1.x86_64.rpm /vagrant/packages/postgresql-8.4.20-6.el6.x86_64.rpm /vagrant/packages/perl-* /vagrant/packages/postgresql-libs-8.4.20-6.el6.x86_64.rpm
This would successfully work without downloading anything, so I then ran:
cd /vagrant/packages/
mkdir save
mv /vagrant/packages/git-1.7.1-4.el6_7.1.x86_64.rpm /vagrant/packages/postgresql-8.4.20-6.el6.x86_64.rpm /vagrant/packages/perl-* /vagrant/packages/postgresql-libs-8.4.20-6.el6.x86_64.rpm save/
rm *.rpm
mv save/* .
rmdir save
Result: A "packages" directory with only the dependencies actually needed from the fresh Vagrant image.
Then by adding the shell provisioning command to my Vagrantfile:
config.vm.provision "shell", inline: <<-SHELL
yum install -C -y /vagrant/packages/*
SHELL
...I have Git and PostgreSQL installed and ready to use after any vagrant up, even if vagrant destroy was run.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f234835%2fhow-to-use-vagrant-provisioning-to-install-a-package-without-download%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
For example, I have a Vagrant box on my Mac (Linux guest on Mac host)
It would be interesting to know which distribution this is... Given that you're trying to use yum I imagine this is some RH/CentOS/.. stuff?
which I primarily want for easy access to built-in Linux documentation (man pages, info pages, etc.) However, the box I am using doesn't have the man package installed when I first vagrant up.
I don't know any distribution that doesn't install manby default.
If I were you, I'd use one of the official boxes on ATLAS, Debian comes to mind: https://vagrantcloud.com/debian/
Reply to Q1
Add this to your vagrantfile:
$script = <<SCRIPT
echo I am provisioning...
date > /etc/vagrant_provisioned_at
SCRIPT
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: $script
end
Example taken from
http://docs.vagrantup.com/v2/provisioning/shell.html#inline-scripts
This would execute the script at the top, resulting in the creation of /etc/vagrant_provisioned_at
Further adapted to your question:
$script = <<SCRIPT
yum install man
SCRIPT
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: $script
end
The provisioning script is run as UID0, so no need for sudo.
Reply to Q2
I'm a Debian user and as such RedHat illiterate ;-)
IMHO this would be rpm -hiv <filename>(i =install, h = hashmarks, v = verbose).
Related manpage
Perfect! Yes, I'm using CentOS; the vm box is "bento/centos-6.7" and it doesn't come with man. (Which is an odd setup; my physical CentOS install does.)rpmisn't smart enough to handle dependencies and just exits with an error if given the single file, BUT it is smart enough to put a list of filename arguments in dependency sequence. Since I already downloaded the dependencies as described in my question, I just usedrpm -i /vagrant/packages/*and it puts them in order and installs them all! (No need for -hv as it's just run during provisioning.)
– Wildcard
Oct 9 '15 at 13:08
1
I found the puppetlabs base boxes quite "vanilla", try one of those: atlas.hashicorp.com/puppetlabs They have a good naming scheme btw...
– Jan
Oct 9 '15 at 13:14
Aha! Even better; I've just switched over. Thanks! Still great to have the provisioning data/know-how; I will use that for my own setup and package installs in the future (rather than stuff likemanwhich should already be there....)
– Wildcard
Oct 9 '15 at 13:28
add a comment |
For example, I have a Vagrant box on my Mac (Linux guest on Mac host)
It would be interesting to know which distribution this is... Given that you're trying to use yum I imagine this is some RH/CentOS/.. stuff?
which I primarily want for easy access to built-in Linux documentation (man pages, info pages, etc.) However, the box I am using doesn't have the man package installed when I first vagrant up.
I don't know any distribution that doesn't install manby default.
If I were you, I'd use one of the official boxes on ATLAS, Debian comes to mind: https://vagrantcloud.com/debian/
Reply to Q1
Add this to your vagrantfile:
$script = <<SCRIPT
echo I am provisioning...
date > /etc/vagrant_provisioned_at
SCRIPT
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: $script
end
Example taken from
http://docs.vagrantup.com/v2/provisioning/shell.html#inline-scripts
This would execute the script at the top, resulting in the creation of /etc/vagrant_provisioned_at
Further adapted to your question:
$script = <<SCRIPT
yum install man
SCRIPT
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: $script
end
The provisioning script is run as UID0, so no need for sudo.
Reply to Q2
I'm a Debian user and as such RedHat illiterate ;-)
IMHO this would be rpm -hiv <filename>(i =install, h = hashmarks, v = verbose).
Related manpage
Perfect! Yes, I'm using CentOS; the vm box is "bento/centos-6.7" and it doesn't come with man. (Which is an odd setup; my physical CentOS install does.)rpmisn't smart enough to handle dependencies and just exits with an error if given the single file, BUT it is smart enough to put a list of filename arguments in dependency sequence. Since I already downloaded the dependencies as described in my question, I just usedrpm -i /vagrant/packages/*and it puts them in order and installs them all! (No need for -hv as it's just run during provisioning.)
– Wildcard
Oct 9 '15 at 13:08
1
I found the puppetlabs base boxes quite "vanilla", try one of those: atlas.hashicorp.com/puppetlabs They have a good naming scheme btw...
– Jan
Oct 9 '15 at 13:14
Aha! Even better; I've just switched over. Thanks! Still great to have the provisioning data/know-how; I will use that for my own setup and package installs in the future (rather than stuff likemanwhich should already be there....)
– Wildcard
Oct 9 '15 at 13:28
add a comment |
For example, I have a Vagrant box on my Mac (Linux guest on Mac host)
It would be interesting to know which distribution this is... Given that you're trying to use yum I imagine this is some RH/CentOS/.. stuff?
which I primarily want for easy access to built-in Linux documentation (man pages, info pages, etc.) However, the box I am using doesn't have the man package installed when I first vagrant up.
I don't know any distribution that doesn't install manby default.
If I were you, I'd use one of the official boxes on ATLAS, Debian comes to mind: https://vagrantcloud.com/debian/
Reply to Q1
Add this to your vagrantfile:
$script = <<SCRIPT
echo I am provisioning...
date > /etc/vagrant_provisioned_at
SCRIPT
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: $script
end
Example taken from
http://docs.vagrantup.com/v2/provisioning/shell.html#inline-scripts
This would execute the script at the top, resulting in the creation of /etc/vagrant_provisioned_at
Further adapted to your question:
$script = <<SCRIPT
yum install man
SCRIPT
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: $script
end
The provisioning script is run as UID0, so no need for sudo.
Reply to Q2
I'm a Debian user and as such RedHat illiterate ;-)
IMHO this would be rpm -hiv <filename>(i =install, h = hashmarks, v = verbose).
Related manpage
For example, I have a Vagrant box on my Mac (Linux guest on Mac host)
It would be interesting to know which distribution this is... Given that you're trying to use yum I imagine this is some RH/CentOS/.. stuff?
which I primarily want for easy access to built-in Linux documentation (man pages, info pages, etc.) However, the box I am using doesn't have the man package installed when I first vagrant up.
I don't know any distribution that doesn't install manby default.
If I were you, I'd use one of the official boxes on ATLAS, Debian comes to mind: https://vagrantcloud.com/debian/
Reply to Q1
Add this to your vagrantfile:
$script = <<SCRIPT
echo I am provisioning...
date > /etc/vagrant_provisioned_at
SCRIPT
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: $script
end
Example taken from
http://docs.vagrantup.com/v2/provisioning/shell.html#inline-scripts
This would execute the script at the top, resulting in the creation of /etc/vagrant_provisioned_at
Further adapted to your question:
$script = <<SCRIPT
yum install man
SCRIPT
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: $script
end
The provisioning script is run as UID0, so no need for sudo.
Reply to Q2
I'm a Debian user and as such RedHat illiterate ;-)
IMHO this would be rpm -hiv <filename>(i =install, h = hashmarks, v = verbose).
Related manpage
answered Oct 9 '15 at 11:14
JanJan
5,3291828
5,3291828
Perfect! Yes, I'm using CentOS; the vm box is "bento/centos-6.7" and it doesn't come with man. (Which is an odd setup; my physical CentOS install does.)rpmisn't smart enough to handle dependencies and just exits with an error if given the single file, BUT it is smart enough to put a list of filename arguments in dependency sequence. Since I already downloaded the dependencies as described in my question, I just usedrpm -i /vagrant/packages/*and it puts them in order and installs them all! (No need for -hv as it's just run during provisioning.)
– Wildcard
Oct 9 '15 at 13:08
1
I found the puppetlabs base boxes quite "vanilla", try one of those: atlas.hashicorp.com/puppetlabs They have a good naming scheme btw...
– Jan
Oct 9 '15 at 13:14
Aha! Even better; I've just switched over. Thanks! Still great to have the provisioning data/know-how; I will use that for my own setup and package installs in the future (rather than stuff likemanwhich should already be there....)
– Wildcard
Oct 9 '15 at 13:28
add a comment |
Perfect! Yes, I'm using CentOS; the vm box is "bento/centos-6.7" and it doesn't come with man. (Which is an odd setup; my physical CentOS install does.)rpmisn't smart enough to handle dependencies and just exits with an error if given the single file, BUT it is smart enough to put a list of filename arguments in dependency sequence. Since I already downloaded the dependencies as described in my question, I just usedrpm -i /vagrant/packages/*and it puts them in order and installs them all! (No need for -hv as it's just run during provisioning.)
– Wildcard
Oct 9 '15 at 13:08
1
I found the puppetlabs base boxes quite "vanilla", try one of those: atlas.hashicorp.com/puppetlabs They have a good naming scheme btw...
– Jan
Oct 9 '15 at 13:14
Aha! Even better; I've just switched over. Thanks! Still great to have the provisioning data/know-how; I will use that for my own setup and package installs in the future (rather than stuff likemanwhich should already be there....)
– Wildcard
Oct 9 '15 at 13:28
Perfect! Yes, I'm using CentOS; the vm box is "bento/centos-6.7" and it doesn't come with man. (Which is an odd setup; my physical CentOS install does.)
rpm isn't smart enough to handle dependencies and just exits with an error if given the single file, BUT it is smart enough to put a list of filename arguments in dependency sequence. Since I already downloaded the dependencies as described in my question, I just used rpm -i /vagrant/packages/* and it puts them in order and installs them all! (No need for -hv as it's just run during provisioning.)– Wildcard
Oct 9 '15 at 13:08
Perfect! Yes, I'm using CentOS; the vm box is "bento/centos-6.7" and it doesn't come with man. (Which is an odd setup; my physical CentOS install does.)
rpm isn't smart enough to handle dependencies and just exits with an error if given the single file, BUT it is smart enough to put a list of filename arguments in dependency sequence. Since I already downloaded the dependencies as described in my question, I just used rpm -i /vagrant/packages/* and it puts them in order and installs them all! (No need for -hv as it's just run during provisioning.)– Wildcard
Oct 9 '15 at 13:08
1
1
I found the puppetlabs base boxes quite "vanilla", try one of those: atlas.hashicorp.com/puppetlabs They have a good naming scheme btw...
– Jan
Oct 9 '15 at 13:14
I found the puppetlabs base boxes quite "vanilla", try one of those: atlas.hashicorp.com/puppetlabs They have a good naming scheme btw...
– Jan
Oct 9 '15 at 13:14
Aha! Even better; I've just switched over. Thanks! Still great to have the provisioning data/know-how; I will use that for my own setup and package installs in the future (rather than stuff like
man which should already be there....)– Wildcard
Oct 9 '15 at 13:28
Aha! Even better; I've just switched over. Thanks! Still great to have the provisioning data/know-how; I will use that for my own setup and package installs in the future (rather than stuff like
man which should already be there....)– Wildcard
Oct 9 '15 at 13:28
add a comment |
I just encountered this use case again; I will make a succinct record here of how I handled it.
I wanted to download (but not install) Git and PostgreSQL, and then install them during the vagrant provision process.
I used the following command from a fresh VM to download the packages with all dependencies (after sudo mkdir /vagrant/packages):
sudo yumdownloader --destdir=/vagrant/packages/ --resolve -y git postgresql
The trick with this command is, it downloads way too much. The next step was to establish the RPMs that I actually needed for the install. I did this by attempting:
sudo yum install /vagrant/packages/git-1.7.1-4.el6_7.1.x86_64.rpm /vagrant/packages/postgresql-8.4.20-6.el6.x86_64.rpm
And pressing "No" at the confirmation prompt because I could see it was planning to download dependencies. I took the listed dependencies and added them to my command:
sudo yum install /vagrant/packages/git-1.7.1-4.el6_7.1.x86_64.rpm /vagrant/packages/postgresql-8.4.20-6.el6.x86_64.rpm /vagrant/packages/perl-* /vagrant/packages/postgresql-libs-8.4.20-6.el6.x86_64.rpm
This would successfully work without downloading anything, so I then ran:
cd /vagrant/packages/
mkdir save
mv /vagrant/packages/git-1.7.1-4.el6_7.1.x86_64.rpm /vagrant/packages/postgresql-8.4.20-6.el6.x86_64.rpm /vagrant/packages/perl-* /vagrant/packages/postgresql-libs-8.4.20-6.el6.x86_64.rpm save/
rm *.rpm
mv save/* .
rmdir save
Result: A "packages" directory with only the dependencies actually needed from the fresh Vagrant image.
Then by adding the shell provisioning command to my Vagrantfile:
config.vm.provision "shell", inline: <<-SHELL
yum install -C -y /vagrant/packages/*
SHELL
...I have Git and PostgreSQL installed and ready to use after any vagrant up, even if vagrant destroy was run.
add a comment |
I just encountered this use case again; I will make a succinct record here of how I handled it.
I wanted to download (but not install) Git and PostgreSQL, and then install them during the vagrant provision process.
I used the following command from a fresh VM to download the packages with all dependencies (after sudo mkdir /vagrant/packages):
sudo yumdownloader --destdir=/vagrant/packages/ --resolve -y git postgresql
The trick with this command is, it downloads way too much. The next step was to establish the RPMs that I actually needed for the install. I did this by attempting:
sudo yum install /vagrant/packages/git-1.7.1-4.el6_7.1.x86_64.rpm /vagrant/packages/postgresql-8.4.20-6.el6.x86_64.rpm
And pressing "No" at the confirmation prompt because I could see it was planning to download dependencies. I took the listed dependencies and added them to my command:
sudo yum install /vagrant/packages/git-1.7.1-4.el6_7.1.x86_64.rpm /vagrant/packages/postgresql-8.4.20-6.el6.x86_64.rpm /vagrant/packages/perl-* /vagrant/packages/postgresql-libs-8.4.20-6.el6.x86_64.rpm
This would successfully work without downloading anything, so I then ran:
cd /vagrant/packages/
mkdir save
mv /vagrant/packages/git-1.7.1-4.el6_7.1.x86_64.rpm /vagrant/packages/postgresql-8.4.20-6.el6.x86_64.rpm /vagrant/packages/perl-* /vagrant/packages/postgresql-libs-8.4.20-6.el6.x86_64.rpm save/
rm *.rpm
mv save/* .
rmdir save
Result: A "packages" directory with only the dependencies actually needed from the fresh Vagrant image.
Then by adding the shell provisioning command to my Vagrantfile:
config.vm.provision "shell", inline: <<-SHELL
yum install -C -y /vagrant/packages/*
SHELL
...I have Git and PostgreSQL installed and ready to use after any vagrant up, even if vagrant destroy was run.
add a comment |
I just encountered this use case again; I will make a succinct record here of how I handled it.
I wanted to download (but not install) Git and PostgreSQL, and then install them during the vagrant provision process.
I used the following command from a fresh VM to download the packages with all dependencies (after sudo mkdir /vagrant/packages):
sudo yumdownloader --destdir=/vagrant/packages/ --resolve -y git postgresql
The trick with this command is, it downloads way too much. The next step was to establish the RPMs that I actually needed for the install. I did this by attempting:
sudo yum install /vagrant/packages/git-1.7.1-4.el6_7.1.x86_64.rpm /vagrant/packages/postgresql-8.4.20-6.el6.x86_64.rpm
And pressing "No" at the confirmation prompt because I could see it was planning to download dependencies. I took the listed dependencies and added them to my command:
sudo yum install /vagrant/packages/git-1.7.1-4.el6_7.1.x86_64.rpm /vagrant/packages/postgresql-8.4.20-6.el6.x86_64.rpm /vagrant/packages/perl-* /vagrant/packages/postgresql-libs-8.4.20-6.el6.x86_64.rpm
This would successfully work without downloading anything, so I then ran:
cd /vagrant/packages/
mkdir save
mv /vagrant/packages/git-1.7.1-4.el6_7.1.x86_64.rpm /vagrant/packages/postgresql-8.4.20-6.el6.x86_64.rpm /vagrant/packages/perl-* /vagrant/packages/postgresql-libs-8.4.20-6.el6.x86_64.rpm save/
rm *.rpm
mv save/* .
rmdir save
Result: A "packages" directory with only the dependencies actually needed from the fresh Vagrant image.
Then by adding the shell provisioning command to my Vagrantfile:
config.vm.provision "shell", inline: <<-SHELL
yum install -C -y /vagrant/packages/*
SHELL
...I have Git and PostgreSQL installed and ready to use after any vagrant up, even if vagrant destroy was run.
I just encountered this use case again; I will make a succinct record here of how I handled it.
I wanted to download (but not install) Git and PostgreSQL, and then install them during the vagrant provision process.
I used the following command from a fresh VM to download the packages with all dependencies (after sudo mkdir /vagrant/packages):
sudo yumdownloader --destdir=/vagrant/packages/ --resolve -y git postgresql
The trick with this command is, it downloads way too much. The next step was to establish the RPMs that I actually needed for the install. I did this by attempting:
sudo yum install /vagrant/packages/git-1.7.1-4.el6_7.1.x86_64.rpm /vagrant/packages/postgresql-8.4.20-6.el6.x86_64.rpm
And pressing "No" at the confirmation prompt because I could see it was planning to download dependencies. I took the listed dependencies and added them to my command:
sudo yum install /vagrant/packages/git-1.7.1-4.el6_7.1.x86_64.rpm /vagrant/packages/postgresql-8.4.20-6.el6.x86_64.rpm /vagrant/packages/perl-* /vagrant/packages/postgresql-libs-8.4.20-6.el6.x86_64.rpm
This would successfully work without downloading anything, so I then ran:
cd /vagrant/packages/
mkdir save
mv /vagrant/packages/git-1.7.1-4.el6_7.1.x86_64.rpm /vagrant/packages/postgresql-8.4.20-6.el6.x86_64.rpm /vagrant/packages/perl-* /vagrant/packages/postgresql-libs-8.4.20-6.el6.x86_64.rpm save/
rm *.rpm
mv save/* .
rmdir save
Result: A "packages" directory with only the dependencies actually needed from the fresh Vagrant image.
Then by adding the shell provisioning command to my Vagrantfile:
config.vm.provision "shell", inline: <<-SHELL
yum install -C -y /vagrant/packages/*
SHELL
...I have Git and PostgreSQL installed and ready to use after any vagrant up, even if vagrant destroy was run.
answered Sep 26 '16 at 9:40
WildcardWildcard
22.9k1065169
22.9k1065169
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f234835%2fhow-to-use-vagrant-provisioning-to-install-a-package-without-download%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown