Create yum variable, that is the result of a command?Installing yum repositories that are specified in...

PTIJ: How can I halachically kill a vampire?

What do you call the air that rushes into your car in the highway?

How does airport security verify that you can carry a battery bank over 100 Wh?

Is having access to past exams cheating and, if yes, could it be proven just by a good grade?

MTG: Can I kill an opponent in response to lethal activated abilities, and not take the damage?

Virginia employer terminated employee and wants signing bonus returned

How do I locate a classical quotation?

How do you like my writing?

Why the color red for the Republican Party

Are babies of evil humanoid species inherently evil?

PTIJ: Why can't I eat anything?

What is the chance of making a successful appeal to dismissal decision from a PhD program after failing the qualifying exam in the 2nd attempt?

Good for you! in Russian

The bar has been raised

Force user to remove USB token

Aliens englobed the Solar System: will we notice?

How do anti-virus programs start at Windows boot?

Make a transparent 448*448 image

Making a sword in the stone, in a medieval world without magic

Placing subfig vertically

Can you reject a postdoc offer after the PI has paid a large sum for flights/accommodation for your visit?

Rejected in 4th interview round citing insufficient years of experience

How strictly should I take "Candidates must be local"?

2×2×2 rubik's cube corner is twisted!



Create yum variable, that is the result of a command?


Installing yum repositories that are specified in kickstart fileyum not working on EC2 Red Hat instance: Cannot retrieve repository metadatayum and command line fieldWhy must yum update its repos on each command?why does yum update fail in cent os 6.4 when wget and curl succeedsYUM, “patchlevel” and the DTAP street on redhat/centosIs it legal to create an RPM which only runs %post scripts to modify a file owned by another RPM?linux + yum update - what this command covers?redhat linux + yum updateinfo list + what is the equivalent command for redhat 5how does yum use the baseurl in the repo file?













1















To clarify, I am looking on how to store a yum variable as the RESULT of a command. The command I use to get the OS version is irrelevant to me, I'm sure there are better ways of getting it than what I've done below.



I want to create a custom yum variable that is the result of running



cat /etc/redhat-release | awk '{ print $3 }'


The documentation for creating variables seems to only allow for creating static variables inside a file in /etc/yum/vars/$variablename.



So what I want is to have /etc/yum/vars/dotrelease be the output of my command above, based on the system I am on.



Then I can set my baseurl repo to http://localrepo.com/repo/centos/$dotrelease/os/$basearch/



My custom repo is separated by dot release, where by default $releasever only looks the numbered release, for example, the $releasever variable on centos6.4 is "6".



I realize I can just



echo (cat /etc/redhat-release | awk '{ print $3 }') > /etc/yum/vars/dotrelease


but I'd have to run that on every machine I deploy, instead of just keeping the variable in a file.










share|improve this question
















bumped to the homepage by Community 6 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • This is a terrible way to go about it. It will return different and quite possibly wrong results on different systems. (I'm sure that you don't want "Enterprise" if you run it on an actual RHEL box.) Just use facter operatingsystemrelease.

    – Michael Hampton
    Aug 11 '14 at 23:51











  • I am trying to do this outside of puppet, and the result will always be the same on a redhat or cent box...

    – Party Time
    Aug 12 '14 at 0:09











  • I didn't say anything about puppet. It's fairly common to use facter with ansible, for instance.

    – Michael Hampton
    Aug 12 '14 at 0:17











  • So your suggestion is install facter, and store the yum variable as the output of 'facter operatingsystemrelease'? That is all well and good but doesn't answer the root of my question which is, how to create a yum variable that is the result of a command. The command to return the dot release of my os is irrelevant.

    – Party Time
    Aug 12 '14 at 0:24











  • @PartyTime How are you distributing the .repo file? Distribute one to your RHEL 6.2 servers and another to your 6.5 servers. Or you can build them dynamically, which is where the facter comes in handy. But is the software for EL6.2 considerably different than EL6.5?

    – ewwhite
    Aug 12 '14 at 0:47
















1















To clarify, I am looking on how to store a yum variable as the RESULT of a command. The command I use to get the OS version is irrelevant to me, I'm sure there are better ways of getting it than what I've done below.



I want to create a custom yum variable that is the result of running



cat /etc/redhat-release | awk '{ print $3 }'


The documentation for creating variables seems to only allow for creating static variables inside a file in /etc/yum/vars/$variablename.



So what I want is to have /etc/yum/vars/dotrelease be the output of my command above, based on the system I am on.



Then I can set my baseurl repo to http://localrepo.com/repo/centos/$dotrelease/os/$basearch/



My custom repo is separated by dot release, where by default $releasever only looks the numbered release, for example, the $releasever variable on centos6.4 is "6".



I realize I can just



echo (cat /etc/redhat-release | awk '{ print $3 }') > /etc/yum/vars/dotrelease


but I'd have to run that on every machine I deploy, instead of just keeping the variable in a file.










share|improve this question
















bumped to the homepage by Community 6 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • This is a terrible way to go about it. It will return different and quite possibly wrong results on different systems. (I'm sure that you don't want "Enterprise" if you run it on an actual RHEL box.) Just use facter operatingsystemrelease.

    – Michael Hampton
    Aug 11 '14 at 23:51











  • I am trying to do this outside of puppet, and the result will always be the same on a redhat or cent box...

    – Party Time
    Aug 12 '14 at 0:09











  • I didn't say anything about puppet. It's fairly common to use facter with ansible, for instance.

    – Michael Hampton
    Aug 12 '14 at 0:17











  • So your suggestion is install facter, and store the yum variable as the output of 'facter operatingsystemrelease'? That is all well and good but doesn't answer the root of my question which is, how to create a yum variable that is the result of a command. The command to return the dot release of my os is irrelevant.

    – Party Time
    Aug 12 '14 at 0:24











  • @PartyTime How are you distributing the .repo file? Distribute one to your RHEL 6.2 servers and another to your 6.5 servers. Or you can build them dynamically, which is where the facter comes in handy. But is the software for EL6.2 considerably different than EL6.5?

    – ewwhite
    Aug 12 '14 at 0:47














1












1








1








To clarify, I am looking on how to store a yum variable as the RESULT of a command. The command I use to get the OS version is irrelevant to me, I'm sure there are better ways of getting it than what I've done below.



I want to create a custom yum variable that is the result of running



cat /etc/redhat-release | awk '{ print $3 }'


The documentation for creating variables seems to only allow for creating static variables inside a file in /etc/yum/vars/$variablename.



So what I want is to have /etc/yum/vars/dotrelease be the output of my command above, based on the system I am on.



Then I can set my baseurl repo to http://localrepo.com/repo/centos/$dotrelease/os/$basearch/



My custom repo is separated by dot release, where by default $releasever only looks the numbered release, for example, the $releasever variable on centos6.4 is "6".



I realize I can just



echo (cat /etc/redhat-release | awk '{ print $3 }') > /etc/yum/vars/dotrelease


but I'd have to run that on every machine I deploy, instead of just keeping the variable in a file.










share|improve this question
















To clarify, I am looking on how to store a yum variable as the RESULT of a command. The command I use to get the OS version is irrelevant to me, I'm sure there are better ways of getting it than what I've done below.



I want to create a custom yum variable that is the result of running



cat /etc/redhat-release | awk '{ print $3 }'


The documentation for creating variables seems to only allow for creating static variables inside a file in /etc/yum/vars/$variablename.



So what I want is to have /etc/yum/vars/dotrelease be the output of my command above, based on the system I am on.



Then I can set my baseurl repo to http://localrepo.com/repo/centos/$dotrelease/os/$basearch/



My custom repo is separated by dot release, where by default $releasever only looks the numbered release, for example, the $releasever variable on centos6.4 is "6".



I realize I can just



echo (cat /etc/redhat-release | awk '{ print $3 }') > /etc/yum/vars/dotrelease


but I'd have to run that on every machine I deploy, instead of just keeping the variable in a file.







linux centos redhat yum






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 12 '14 at 0:27







Party Time

















asked Aug 11 '14 at 23:13









Party TimeParty Time

255




255





bumped to the homepage by Community 6 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 6 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • This is a terrible way to go about it. It will return different and quite possibly wrong results on different systems. (I'm sure that you don't want "Enterprise" if you run it on an actual RHEL box.) Just use facter operatingsystemrelease.

    – Michael Hampton
    Aug 11 '14 at 23:51











  • I am trying to do this outside of puppet, and the result will always be the same on a redhat or cent box...

    – Party Time
    Aug 12 '14 at 0:09











  • I didn't say anything about puppet. It's fairly common to use facter with ansible, for instance.

    – Michael Hampton
    Aug 12 '14 at 0:17











  • So your suggestion is install facter, and store the yum variable as the output of 'facter operatingsystemrelease'? That is all well and good but doesn't answer the root of my question which is, how to create a yum variable that is the result of a command. The command to return the dot release of my os is irrelevant.

    – Party Time
    Aug 12 '14 at 0:24











  • @PartyTime How are you distributing the .repo file? Distribute one to your RHEL 6.2 servers and another to your 6.5 servers. Or you can build them dynamically, which is where the facter comes in handy. But is the software for EL6.2 considerably different than EL6.5?

    – ewwhite
    Aug 12 '14 at 0:47



















  • This is a terrible way to go about it. It will return different and quite possibly wrong results on different systems. (I'm sure that you don't want "Enterprise" if you run it on an actual RHEL box.) Just use facter operatingsystemrelease.

    – Michael Hampton
    Aug 11 '14 at 23:51











  • I am trying to do this outside of puppet, and the result will always be the same on a redhat or cent box...

    – Party Time
    Aug 12 '14 at 0:09











  • I didn't say anything about puppet. It's fairly common to use facter with ansible, for instance.

    – Michael Hampton
    Aug 12 '14 at 0:17











  • So your suggestion is install facter, and store the yum variable as the output of 'facter operatingsystemrelease'? That is all well and good but doesn't answer the root of my question which is, how to create a yum variable that is the result of a command. The command to return the dot release of my os is irrelevant.

    – Party Time
    Aug 12 '14 at 0:24











  • @PartyTime How are you distributing the .repo file? Distribute one to your RHEL 6.2 servers and another to your 6.5 servers. Or you can build them dynamically, which is where the facter comes in handy. But is the software for EL6.2 considerably different than EL6.5?

    – ewwhite
    Aug 12 '14 at 0:47

















This is a terrible way to go about it. It will return different and quite possibly wrong results on different systems. (I'm sure that you don't want "Enterprise" if you run it on an actual RHEL box.) Just use facter operatingsystemrelease.

– Michael Hampton
Aug 11 '14 at 23:51





This is a terrible way to go about it. It will return different and quite possibly wrong results on different systems. (I'm sure that you don't want "Enterprise" if you run it on an actual RHEL box.) Just use facter operatingsystemrelease.

– Michael Hampton
Aug 11 '14 at 23:51













I am trying to do this outside of puppet, and the result will always be the same on a redhat or cent box...

– Party Time
Aug 12 '14 at 0:09





I am trying to do this outside of puppet, and the result will always be the same on a redhat or cent box...

– Party Time
Aug 12 '14 at 0:09













I didn't say anything about puppet. It's fairly common to use facter with ansible, for instance.

– Michael Hampton
Aug 12 '14 at 0:17





I didn't say anything about puppet. It's fairly common to use facter with ansible, for instance.

– Michael Hampton
Aug 12 '14 at 0:17













So your suggestion is install facter, and store the yum variable as the output of 'facter operatingsystemrelease'? That is all well and good but doesn't answer the root of my question which is, how to create a yum variable that is the result of a command. The command to return the dot release of my os is irrelevant.

– Party Time
Aug 12 '14 at 0:24





So your suggestion is install facter, and store the yum variable as the output of 'facter operatingsystemrelease'? That is all well and good but doesn't answer the root of my question which is, how to create a yum variable that is the result of a command. The command to return the dot release of my os is irrelevant.

– Party Time
Aug 12 '14 at 0:24













@PartyTime How are you distributing the .repo file? Distribute one to your RHEL 6.2 servers and another to your 6.5 servers. Or you can build them dynamically, which is where the facter comes in handy. But is the software for EL6.2 considerably different than EL6.5?

– ewwhite
Aug 12 '14 at 0:47





@PartyTime How are you distributing the .repo file? Distribute one to your RHEL 6.2 servers and another to your 6.5 servers. Or you can build them dynamically, which is where the facter comes in handy. But is the software for EL6.2 considerably different than EL6.5?

– ewwhite
Aug 12 '14 at 0:47










1 Answer
1






active

oldest

votes


















0














Is puppet in your environment at all?



# facter operatingsystemrelease
6.5


Is quite clean...



But in your local repository, are you actually distributing different packages depending on the point release of your EL system? That may not make sense, as EL tends to automatically move/update to the newest point release within a major version. E.g. You won't see many people running RHEL 6.2 today, because there are no updates available.






share|improve this answer


























  • I am trying to do this outside of puppet. We maintain multiple versions of rhel and centos in house, so I need to have a repo for my 6.2 hosts, and a repo for my 6.5 hosts

    – Party Time
    Aug 12 '14 at 0:08








  • 1





    You can still use the facter tool without Puppet.

    – ewwhite
    Aug 12 '14 at 0:12











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "2"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f619707%2fcreate-yum-variable-that-is-the-result-of-a-command%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Is puppet in your environment at all?



# facter operatingsystemrelease
6.5


Is quite clean...



But in your local repository, are you actually distributing different packages depending on the point release of your EL system? That may not make sense, as EL tends to automatically move/update to the newest point release within a major version. E.g. You won't see many people running RHEL 6.2 today, because there are no updates available.






share|improve this answer


























  • I am trying to do this outside of puppet. We maintain multiple versions of rhel and centos in house, so I need to have a repo for my 6.2 hosts, and a repo for my 6.5 hosts

    – Party Time
    Aug 12 '14 at 0:08








  • 1





    You can still use the facter tool without Puppet.

    – ewwhite
    Aug 12 '14 at 0:12
















0














Is puppet in your environment at all?



# facter operatingsystemrelease
6.5


Is quite clean...



But in your local repository, are you actually distributing different packages depending on the point release of your EL system? That may not make sense, as EL tends to automatically move/update to the newest point release within a major version. E.g. You won't see many people running RHEL 6.2 today, because there are no updates available.






share|improve this answer


























  • I am trying to do this outside of puppet. We maintain multiple versions of rhel and centos in house, so I need to have a repo for my 6.2 hosts, and a repo for my 6.5 hosts

    – Party Time
    Aug 12 '14 at 0:08








  • 1





    You can still use the facter tool without Puppet.

    – ewwhite
    Aug 12 '14 at 0:12














0












0








0







Is puppet in your environment at all?



# facter operatingsystemrelease
6.5


Is quite clean...



But in your local repository, are you actually distributing different packages depending on the point release of your EL system? That may not make sense, as EL tends to automatically move/update to the newest point release within a major version. E.g. You won't see many people running RHEL 6.2 today, because there are no updates available.






share|improve this answer















Is puppet in your environment at all?



# facter operatingsystemrelease
6.5


Is quite clean...



But in your local repository, are you actually distributing different packages depending on the point release of your EL system? That may not make sense, as EL tends to automatically move/update to the newest point release within a major version. E.g. You won't see many people running RHEL 6.2 today, because there are no updates available.







share|improve this answer














share|improve this answer



share|improve this answer








edited Aug 12 '14 at 0:12

























answered Aug 11 '14 at 23:51









ewwhiteewwhite

174k75368719




174k75368719













  • I am trying to do this outside of puppet. We maintain multiple versions of rhel and centos in house, so I need to have a repo for my 6.2 hosts, and a repo for my 6.5 hosts

    – Party Time
    Aug 12 '14 at 0:08








  • 1





    You can still use the facter tool without Puppet.

    – ewwhite
    Aug 12 '14 at 0:12



















  • I am trying to do this outside of puppet. We maintain multiple versions of rhel and centos in house, so I need to have a repo for my 6.2 hosts, and a repo for my 6.5 hosts

    – Party Time
    Aug 12 '14 at 0:08








  • 1





    You can still use the facter tool without Puppet.

    – ewwhite
    Aug 12 '14 at 0:12

















I am trying to do this outside of puppet. We maintain multiple versions of rhel and centos in house, so I need to have a repo for my 6.2 hosts, and a repo for my 6.5 hosts

– Party Time
Aug 12 '14 at 0:08







I am trying to do this outside of puppet. We maintain multiple versions of rhel and centos in house, so I need to have a repo for my 6.2 hosts, and a repo for my 6.5 hosts

– Party Time
Aug 12 '14 at 0:08






1




1





You can still use the facter tool without Puppet.

– ewwhite
Aug 12 '14 at 0:12





You can still use the facter tool without Puppet.

– ewwhite
Aug 12 '14 at 0:12


















draft saved

draft discarded




















































Thanks for contributing an answer to Server Fault!


  • 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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f619707%2fcreate-yum-variable-that-is-the-result-of-a-command%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

Список ссавців Італії Природоохоронні статуси | Список |...

Українські прізвища Зміст Історичні відомості |...