From e308404556f345ae9ba551dae2fec7f7efa1f6f0 Mon Sep 17 00:00:00 2001 From: Loren Gordon Date: Wed, 14 Aug 2019 08:34:31 -0700 Subject: [PATCH 1/5] Creates yum repo defs for python3 salt repo --- defs/main.tf | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/defs/main.tf b/defs/main.tf index 3daf3db..54b8eec 100644 --- a/defs/main.tf +++ b/defs/main.tf @@ -34,6 +34,16 @@ data "null_data_source" "el7" { } } +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" + } +} + data "template_file" "amzn" { count = "${local.skip_module ? 0 : length(local.salt_versions)}" @@ -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)}" @@ -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}" @@ -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", @@ -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", ] } From c2ef0a7e1d559a63bca7687b883ee63c25b2f337 Mon Sep 17 00:00:00 2001 From: Loren Gordon Date: Thu, 15 Aug 2019 06:48:30 -0700 Subject: [PATCH 2/5] Syncs salt python3 repo --- repo/main.tf | 36 ++++++++++++++++++++++++++++++++---- repo/variables.tf | 5 +++++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/repo/main.tf b/repo/main.tf index 08cd115..45d7dfa 100644 --- a/repo/main.tf +++ b/repo/main.tf @@ -5,7 +5,7 @@ locals { } locals { - rsync_command = [ + rsync_base = [ "rsync -vazmH --no-links --numeric-ids --delete --delete-excluded --delete-after", "--exclude \"*/SRPMS\"", "--exclude \"*/i386*\"", @@ -13,20 +13,45 @@ locals { "--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, var.cache_dir)) + }" + + rsync_python3 = "${concat( + local.rsync_base, + list(var.salt_python3_rsync_url, "${var.cache_dir}/python3")) + }" } resource "null_resource" "pull" { count = "${local.skip_module ? 0 : 1}" provisioner "local-exec" { - command = "${join(" ", local.rsync_command)}" + command = "${join(" ", local.rsync_python2)}" + } + + triggers { + salt_versions = "${join(",", local.salt_versions)}" + } +} + +resource "null_resource" "pull_python3" { + count = "${local.skip_module ? 0 : 1}" + + provisioner "local-exec" { + command = "${join(" ", local.rsync_python3)}" } triggers { salt_versions = "${join(",", local.salt_versions)}" } + + depends_on = [ + "null_resource.pull", + ] } locals { @@ -59,5 +84,8 @@ resource "null_resource" "push" { s3_command = "${join(" ", local.s3_command)}" } - depends_on = ["null_resource.pull"] + depends_on = [ + "null_resource.pull", + "null_resource.pull_python3", + ] } diff --git a/repo/variables.tf b/repo/variables.tf index ec2d498..2f0399a 100644 --- a/repo/variables.tf +++ b/repo/variables.tf @@ -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" From fdd252de8e30986d825672bf4e6fcbc1f561db9a Mon Sep 17 00:00:00 2001 From: Loren Gordon Date: Thu, 15 Aug 2019 07:15:10 -0700 Subject: [PATCH 3/5] Ensures the local directory exists for rsync --- repo/main.tf | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/repo/main.tf b/repo/main.tf index 45d7dfa..fe4127a 100644 --- a/repo/main.tf +++ b/repo/main.tf @@ -2,6 +2,7 @@ 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" } locals { @@ -22,36 +23,40 @@ locals { rsync_python3 = "${concat( local.rsync_base, - list(var.salt_python3_rsync_url, "${var.cache_dir}/python3")) + list(var.salt_python3_rsync_url, local.cache_dir_python3)) }" } resource "null_resource" "pull" { count = "${local.skip_module ? 0 : 1}" + provisioner "local-exec" { + command = "mkdir -p ${local.cache_dir_python2}" + } + provisioner "local-exec" { command = "${join(" ", local.rsync_python2)}" } triggers { - salt_versions = "${join(",", local.salt_versions)}" + 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)}" } - - depends_on = [ - "null_resource.pull", - ] } locals { @@ -80,7 +85,8 @@ 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)}" } From ba33003ef2a458d0734e24bfbd7e72c097f745ec Mon Sep 17 00:00:00 2001 From: Loren Gordon Date: Thu, 15 Aug 2019 07:53:10 -0700 Subject: [PATCH 4/5] Moves python2 repo into separate subdirectory --- defs/main.tf | 12 ++++++------ repo/main.tf | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/defs/main.tf b/defs/main.tf index 54b8eec..6a77b1c 100644 --- a/defs/main.tf +++ b/defs/main.tf @@ -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" } } @@ -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" } } @@ -29,8 +29,8 @@ 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" } } diff --git a/repo/main.tf b/repo/main.tf index fe4127a..7cc93d2 100644 --- a/repo/main.tf +++ b/repo/main.tf @@ -3,6 +3,7 @@ locals { 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 { @@ -18,7 +19,7 @@ locals { rsync_python2 = "${concat( local.rsync_base, - list(var.salt_rsync_url, var.cache_dir)) + list(var.salt_rsync_url, local.cache_dir_python2)) }" rsync_python3 = "${concat( From d3730e08475ad3b310c469d327feba2c4d9059e4 Mon Sep 17 00:00:00 2001 From: Loren Gordon Date: Thu, 15 Aug 2019 08:58:34 -0700 Subject: [PATCH 5/5] Bumps version to 2.1.0 --- .bumpversion.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 5e8e094..ba91a7b 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -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