Skip to content

Commit

Permalink
Improved code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
seocam committed Mar 26, 2015
1 parent 3ef7fdf commit 8e13f67
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
present, installed: {
$index_url_arg = $index_url ? {
undef => '',
defaults => "--index_url=$index_url",
defaults => "--index_url=${index_url}",
}

if $version != undef {
$package_with_version = "$package==$version"
$grep_for = "^$package_with_version$"
$package_with_version = "${package}==${version}"
$grep_for = "^${package_with_version}$"
} else {
$package_with_version = $package
$grep_for = "^$package=="
$grep_for = "^${package}=="
}

exec { "install-$package":
command => "pip$python_version install $index_url_arg $package_with_version",
unless => "pip$python_version freeze | grep '$grep_for'",
exec { "install-${package}":
command => "pip${python_version} install ${index_url_arg} ${package_with_version}",
unless => "pip${python_version} freeze | grep '${grep_for}'",
}
}

Expand All @@ -38,9 +38,9 @@
}

absent, purged: {
exec { "uninstall-$package":
command => "pip$python_version uninstall $package -y",
onlyif => "pip$python_version freeze | cut -d= -f1 | egrep '^$package$'",
exec { "uninstall-${package}":
command => "pip${python_version} uninstall ${package} -y",
onlyif => "pip${python_version} freeze | cut -d= -f1 | egrep '^${package}$'",
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions manifests/installation.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
require => Package['curl'],
}

exec { "install-pip$python_version":
command => "curl -L $get_pip_url | python$python_version",
unless => "which pip$python_version",
onlyif => "which python$python_version",
exec { "install-pip${python_version}":
command => "curl -L ${get_pip_url} | python${python_version}",
unless => "which pip${python_version}",
onlyif => "which python${python_version}",
}

}

0 comments on commit 8e13f67

Please sign in to comment.