Module: Cyclid::API::Plugins::Helpers::Redhat
Overview
Redhatish provisioner helper methods
Instance Method Summary collapse
-
#import_signing_key(transport, key_url) ⇒ Object
Import a signing key with RPM.
-
#install_yum_utils(transport) ⇒ Object
Install the yum-utils package.
-
#prepare_fedora_dnf(transport, env) ⇒ Object
Use DNF to configure & install Fedora.
-
#prepare_fedora_yum(transport, env) ⇒ Object
Use YUM to configure & install Fedora.
-
#prepare_redhat(transport, env) ⇒ Object
Use YUM to configure & install a Redhat-like (RHEL, CentOS etc.).
-
#prepare_redhat_5(transport, env) ⇒ Object
Use YUM & RPM to configure & install a Redhat-like (RHEL, CentOS etc.).
-
#quiet ⇒ Object
Insert the –quiet flag if required.
-
#yum_add_repo(transport, url) ⇒ Object
Add a repository with yum-config-manager.
-
#yum_groupinstall(transport, groups) ⇒ Object
Install a package group with yum.
-
#yum_install(transport, packages) ⇒ Object
Install a list of packages with yum.
Instance Method Details
#import_signing_key(transport, key_url) ⇒ Object
Import a signing key with RPM
37 38 39 |
# File 'app/cyclid/plugins/provisioner/redhat/helpers.rb', line 37 def import_signing_key(transport, key_url) transport.exec("rpm #{quiet} --import #{key_url}", sudo: true) end |
#install_yum_utils(transport) ⇒ Object
Install the yum-utils package
32 33 34 |
# File 'app/cyclid/plugins/provisioner/redhat/helpers.rb', line 32 def install_yum_utils(transport) transport.exec('yum install -q -y yum-utils', sudo: true) end |
#prepare_fedora_dnf(transport, env) ⇒ Object
Use DNF to configure & install Fedora
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/cyclid/plugins/provisioner/redhat/helpers.rb', line 58 def prepare_fedora_dnf(transport, env) Cyclid.logger.debug 'using DNF' if env.key? :repos # We need the config-manager plugin transport.exec("dnf install #{quiet} -y 'dnf-command(config-manager)'", sudo: true) env[:repos].each do |repo| next unless repo.key? :url # If there's a key, install it import_signing_key(transport, repo[:key_url]) \ if repo.key? :key_url if repo[:url] =~ /\.rpm$/ # If the URL is an RPM just install it transport.exec("dnf install #{quiet} -y #{repo[:url]}", sudo: true) else # Not an RPM? Let's hope it's a repo file transport.exec("dnf config-manager #{quiet} --add-repo #{repo[:url]}", sudo: true) end end end if env.key? :groups groups = env[:groups].map{ |g| "\"#{g}\"" }.join(' ') transport.exec("dnf groups install #{quiet} -y #{groups}", sudo: true) end transport.exec("dnf install #{quiet} -y #{env[:packages].join(' ')}", sudo: true) \ if env.key? :packages end |
#prepare_fedora_yum(transport, env) ⇒ Object
Use YUM to configure & install Fedora
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'app/cyclid/plugins/provisioner/redhat/helpers.rb', line 92 def prepare_fedora_yum(transport, env) Cyclid.logger.debug 'using YUM' if env.key? :repos # We'll need yum-utils for yum-config-manager install_yum_utils(transport) env[:repos].each do |repo| next unless repo.key? :url # If there's a key, install it import_signing_key(transport, repo[:key_url]) \ if repo.key? :key_url if repo[:url] =~ /\.rpm$/ # If the URL is an RPM just install it transport.exec("yum install #{quiet} -y --nogpgcheck #{repo[:url]}", sudo: true) else # Not an RPM? Let's hope it's a repo file yum_add_repo(transport, repo[:url]) end end end yum_groupinstall(transport, env[:groups]) \ if env.key? :groups yum_install(transport, env[:packages]) \ if env.key? :packages end |
#prepare_redhat(transport, env) ⇒ Object
Use YUM to configure & install a Redhat-like (RHEL, CentOS etc.)
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'app/cyclid/plugins/provisioner/redhat/helpers.rb', line 124 def prepare_redhat(transport, env) Cyclid.logger.debug 'using YUM' if env.key? :repos # We'll need yum-utils for yum-config-manager install_yum_utils(transport) env[:repos].each do |repo| next unless repo.key? :url # If there's a key, install it import_signing_key(transport, repo[:key_url]) \ if repo.key? :key_url if repo[:url] =~ /\.rpm$/ # If the URL is an RPM just install it transport.exec("yum localinstall #{quiet} -y --nogpgcheck #{repo[:url]}", \ sudo: true) else # Not an RPM? Let's hope it's a repo file yum_add_repo(transport, repo[:url]) end end end yum_groupinstall(transport, env[:groups]) \ if env.key? :groups yum_install(transport, env[:packages]) \ if env.key? :packages end |
#prepare_redhat_5(transport, env) ⇒ Object
Use YUM & RPM to configure & install a Redhat-like (RHEL, CentOS etc.)
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'app/cyclid/plugins/provisioner/redhat/helpers.rb', line 157 def prepare_redhat_5(transport, env) if env.key? :repos env[:repos].each do |repo| next unless repo.key? :url # If there's a key, install it import_signing_key(transport, repo[:key_url]) \ if repo.key? :key_url # Assume the URL is an RPM transport.exec("rpm -U #{quiet} #{repo[:url]}", sudo: true) end end yum_groupinstall(transport, env[:groups]) \ if env.key? :groups yum_install(transport, env[:packages]) \ if env.key? :packages end |
#quiet ⇒ Object
Insert the –quiet flag if required
27 28 29 |
# File 'app/cyclid/plugins/provisioner/redhat/helpers.rb', line 27 def quiet @quiet ? '-q' : '' end |
#yum_add_repo(transport, url) ⇒ Object
Add a repository with yum-config-manager
53 54 55 |
# File 'app/cyclid/plugins/provisioner/redhat/helpers.rb', line 53 def yum_add_repo(transport, url) transport.exec("yum-config-manager #{quiet} --add-repo #{url}", sudo: true) end |
#yum_groupinstall(transport, groups) ⇒ Object
Install a package group with yum
42 43 44 45 |
# File 'app/cyclid/plugins/provisioner/redhat/helpers.rb', line 42 def yum_groupinstall(transport, groups) grouplist = groups.map{ |g| "\"#{g}\"" }.join(' ') transport.exec("yum groupinstall #{quiet} -y #{grouplist}", sudo: true) end |
#yum_install(transport, packages) ⇒ Object
Install a list of packages with yum
48 49 50 |
# File 'app/cyclid/plugins/provisioner/redhat/helpers.rb', line 48 def yum_install(transport, packages) transport.exec("yum install #{quiet} -y #{packages.join(' ')}", sudo: true) end |