Skip to content

Commit

Permalink
Merge pull request #15 from lorengordon/salt-py3
Browse files Browse the repository at this point in the history
Creates mirror of salt python3 repo
  • Loading branch information
lorengordon authored Aug 16, 2019
2 parents e4c2b32 + d3730e0 commit e355ca2
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.0.5
current_version = 2.1.0
commit = True
message = Bumps version to {new_version}
tag = False
Expand Down
50 changes: 44 additions & 6 deletions defs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ data "null_data_source" "amzn" {

inputs {
name = "salt-reposync-amzn"
baseurl = "${local.repo_prefix}/amazon/latest/$basearch/archive/${local.salt_versions[count.index]}"
gpgkey = "${local.repo_prefix}/amazon/latest/$basearch/archive/${local.salt_versions[count.index]}/SALTSTACK-GPG-KEY.pub"
baseurl = "${local.repo_prefix}/python2/amazon/latest/$basearch/archive/${local.salt_versions[count.index]}"
gpgkey = "${local.repo_prefix}/python2/amazon/latest/$basearch/archive/${local.salt_versions[count.index]}/SALTSTACK-GPG-KEY.pub"
}
}

Expand All @@ -19,8 +19,8 @@ data "null_data_source" "el6" {

inputs {
name = "salt-reposync-el6"
baseurl = "${local.repo_prefix}/redhat/6/$basearch/archive/${local.salt_versions[count.index]}"
gpgkey = "${local.repo_prefix}/redhat/6/$basearch/archive/${local.salt_versions[count.index]}/SALTSTACK-GPG-KEY.pub"
baseurl = "${local.repo_prefix}/python2/redhat/6/$basearch/archive/${local.salt_versions[count.index]}"
gpgkey = "${local.repo_prefix}/python2/redhat/6/$basearch/archive/${local.salt_versions[count.index]}/SALTSTACK-GPG-KEY.pub"
}
}

Expand All @@ -29,8 +29,18 @@ data "null_data_source" "el7" {

inputs {
name = "salt-reposync-el7"
baseurl = "${local.repo_prefix}/redhat/7/$basearch/archive/${local.salt_versions[count.index]}"
gpgkey = "${local.repo_prefix}/redhat/7/$basearch/archive/${local.salt_versions[count.index]}/SALTSTACK-GPG-KEY.pub"
baseurl = "${local.repo_prefix}/python2/redhat/7/$basearch/archive/${local.salt_versions[count.index]}"
gpgkey = "${local.repo_prefix}/python2/redhat/7/$basearch/archive/${local.salt_versions[count.index]}/SALTSTACK-GPG-KEY.pub"
}
}

data "null_data_source" "el7_python3" {
count = "${local.skip_module ? 0 : length(local.salt_versions)}"

inputs {
name = "salt-reposync-el7-python3"
baseurl = "${local.repo_prefix}/python3/7/$basearch/archive/${local.salt_versions[count.index]}"
gpgkey = "${local.repo_prefix}/python3/7/$basearch/archive/${local.salt_versions[count.index]}/SALTSTACK-GPG-KEY.pub"
}
}

Expand Down Expand Up @@ -70,6 +80,18 @@ data "template_file" "el7" {
}
}

data "template_file" "el7_python3" {
count = "${local.skip_module ? 0 : length(local.salt_versions)}"

template = "${file("${path.module}/yum.repo")}"

vars {
name = "${lookup(data.null_data_source.el7_python3.*.outputs[count.index], "name")}"
baseurl = "${lookup(data.null_data_source.el7_python3.*.outputs[count.index], "baseurl")}"
gpgkey = "${lookup(data.null_data_source.el7_python3.*.outputs[count.index], "gpgkey")}"
}
}

resource "local_file" "amzn" {
count = "${local.skip_module ? 0 : length(local.salt_versions)}"

Expand All @@ -91,6 +113,13 @@ resource "local_file" "el7" {
filename = "${var.cache_dir}/${local.salt_versions[count.index]}/salt-reposync-el7.repo"
}

resource "local_file" "el7_python3" {
count = "${local.skip_module ? 0 : length(local.salt_versions)}"

content = "${data.template_file.el7_python3.*.rendered[count.index]}"
filename = "${var.cache_dir}/${local.salt_versions[count.index]}/salt-reposync-el7-python3.repo"
}

resource "local_file" "amzn_default" {
count = "${local.skip_module ? 0 : 1}"

Expand All @@ -112,6 +141,13 @@ resource "local_file" "el7_default" {
filename = "${var.cache_dir}/salt-reposync-el7.repo"
}

resource "local_file" "el7_python3_default" {
count = "${local.skip_module ? 0 : 1}"

content = "${data.template_file.el7_python3.*.rendered[index(local.salt_versions, var.salt_version)]}"
filename = "${var.cache_dir}/salt-reposync-el7-python3.repo"
}

locals {
s3_command = [
"aws s3 sync --delete",
Expand Down Expand Up @@ -147,8 +183,10 @@ resource "null_resource" "push" {
"local_file.amzn",
"local_file.el6",
"local_file.el7",
"local_file.el7_python3",
"local_file.amzn_default",
"local_file.el6_default",
"local_file.el7_default",
"local_file.el7_python3_default",
]
}
47 changes: 41 additions & 6 deletions repo/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,61 @@ locals {
skip_module = "${var.salt_version == ""}"
salt_versions = "${sort(distinct(concat(list(var.salt_version), var.extra_salt_versions)))}"
salt_versions_include = "${formatlist("--include \"*/%s/**\"", local.salt_versions)}"
cache_dir_python3 = "${var.cache_dir}/python3"
cache_dir_python2 = "${var.cache_dir}/python2"
}

locals {
rsync_command = [
rsync_base = [
"rsync -vazmH --no-links --numeric-ids --delete --delete-excluded --delete-after",
"--exclude \"*/SRPMS\"",
"--exclude \"*/i386*\"",
"--exclude \"redhat/5*\"",
"--include \"*/\"",
"${join(" ", local.salt_versions_include)}",
"--exclude \"*\"",
"${var.salt_rsync_url} ${var.cache_dir}",
]

rsync_python2 = "${concat(
local.rsync_base,
list(var.salt_rsync_url, local.cache_dir_python2))
}"

rsync_python3 = "${concat(
local.rsync_base,
list(var.salt_python3_rsync_url, local.cache_dir_python3))
}"
}

resource "null_resource" "pull" {
count = "${local.skip_module ? 0 : 1}"

provisioner "local-exec" {
command = "${join(" ", local.rsync_command)}"
command = "mkdir -p ${local.cache_dir_python2}"
}

provisioner "local-exec" {
command = "${join(" ", local.rsync_python2)}"
}

triggers {
rsync_python2 = "${join(" ", local.rsync_python2)}"
}
}

resource "null_resource" "pull_python3" {
count = "${local.skip_module ? 0 : 1}"

provisioner "local-exec" {
command = "mkdir -p ${local.cache_dir_python3}"
}

provisioner "local-exec" {
command = "${join(" ", local.rsync_python3)}"
}

triggers {
salt_versions = "${join(",", local.salt_versions)}"
rsync_python3 = "${join(" ", local.rsync_python3)}"
}
}

Expand Down Expand Up @@ -55,9 +86,13 @@ resource "null_resource" "push" {
}

triggers {
salt_versions = "${join(",", local.salt_versions)}"
rsync_python2 = "${join(" ", local.rsync_python2)}"
rsync_python3 = "${join(" ", local.rsync_python3)}"
s3_command = "${join(" ", local.s3_command)}"
}

depends_on = ["null_resource.pull"]
depends_on = [
"null_resource.pull",
"null_resource.pull_python3",
]
}
5 changes: 5 additions & 0 deletions repo/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ variable "salt_rsync_url" {
default = "rsync://rsync.repo.saltstack.com/saltstack_pkgrepo_rhel"
}

variable "salt_python3_rsync_url" {
type = "string"
default = "rsync://rsync.repo.saltstack.com/saltstack_pkgrepo_rhel_python3"
}

variable "cache_dir" {
type = "string"
default = ".filecache"
Expand Down

0 comments on commit e355ca2

Please sign in to comment.