diff --git a/modules/openstack_project/files/pypi-mirror.yaml b/modules/openstack_project/files/pypi-mirror.yaml new file mode 100644 index 0000000000..3ed9175000 --- /dev/null +++ b/modules/openstack_project/files/pypi-mirror.yaml @@ -0,0 +1,15 @@ +# This file is managed by puppet. +# https://github.com/openstack-infra/config + +cache-root: /var/cache/pypimirror + +mirrors: + - name: openstack + projects: + - https://github.com/openstack/requirements + output: /var/lib/pypimirror/openstack + + - name: openstack-infra + projects: + - https://github.com/openstack-infra/config + output: /var/lib/pypimirror/openstack-infra diff --git a/modules/openstack_project/manifests/pypi.pp b/modules/openstack_project/manifests/pypi.pp index 4dc4845d4e..f2eede4267 100644 --- a/modules/openstack_project/manifests/pypi.pp +++ b/modules/openstack_project/manifests/pypi.pp @@ -18,6 +18,19 @@ class openstack_project::pypi ( } class { 'pypimirror': - projects => $openstack_project::project_list, + mirror_config => '/etc/openstackci/pypi-mirror.yaml', } + + file { '/etc/openstackci': + ensure => directory, + mode => '0755', + owner => 'root', + group => 'root', + } + + file { '/etc/openstackci/pypi-mirror.yaml': + ensure => present, + source => 'puppet:///modules/openstack_project/pypi-mirror.yaml', + } + } diff --git a/modules/pypimirror/manifests/init.pp b/modules/pypimirror/manifests/init.pp index db110c0725..be70ba4507 100644 --- a/modules/pypimirror/manifests/init.pp +++ b/modules/pypimirror/manifests/init.pp @@ -2,95 +2,86 @@ # class pypimirror( $vhost_name = $::fqdn, - $log_filename = '/var/log/pypimirror.log', - $mirror_file_path = '/var/lib/pypimirror', - $pip_download = '/var/lib/pip-download', - $pip_cache = '/var/cache/pip', - $git_source = 'https://github.com', - $local_git_dir = '/var/lib/git', - $ssh_project_key = 'UNDEF', - $projects = [] + $mirror_config = '', + $mirror_root = '/var/lib/pypimirror', ) { include apache include pip - include remove_nginx include jeepyb + $log_root = '/var/log/pypimirror/' + $log_filename = "${log_root}/pypimirror.log" + $cache_root = '/var/cache/pypimirror' + if ! defined(Package['python-yaml']) { package { 'python-yaml': ensure => present, } } - file { '/usr/local/mirror_scripts': - ensure => directory, - mode => '0755', - owner => 'root', - group => 'root', + user { 'mirror': + ensure => present, + home => '/home/mirror', + shell => '/bin/bash', + gid => 'mirror', + managehome => true, + require => Group['mirror'], } - file { $pip_download: - ensure => directory, - mode => '0755', - owner => 'root', - group => 'root', + group { 'mirror': + ensure => present, } - file { $pip_cache: - ensure => directory, - mode => '0755', - owner => 'root', - group => 'root', + file { $log_root: + ensure => directory, + mode => '0755', + owner => 'mirror', + group => 'mirror', + require => User['mirror'], } - file { '/etc/openstackci': - ensure => directory, - owner => 'root', + file { $cache_root: + ensure => directory, + mode => '0755', + owner => 'mirror', + group => 'mirror', + require => User['mirror'], } - file { '/etc/openstackci/projects.yaml': - ensure => present, - owner => 'root', - group => 'root', - mode => '0444', - content => template('openstack_project/review.projects.yaml.erb'), - replace => true, + file { $mirror_root: + ensure => directory, + mode => '0755', + owner => 'mirror', + group => 'mirror', + require => User['mirror'], } - file { '/usr/local/mirror_scripts/run-mirror.sh': + file { '/usr/local/bin/run-mirror.sh': ensure => present, mode => '0755', owner => 'root', group => 'root', content => template('pypimirror/run-mirror.sh.erb'), - require => [ - File['/usr/local/mirror_scripts'], - Class[pip], - ], - } - - file { '/usr/local/mirror_scripts/run_mirror.py': - ensure => absent, - } - - file { '/usr/local/mirror_scripts/pull-repo.sh': - ensure => absent, - } - - file { '/usr/local/mirror_scripts/process_cache.py': - ensure => absent, } # Add cron job to update the mirror cron { 'update_mirror': + ensure => absent, user => 'root', hour => '0', - command => '/usr/local/mirror_scripts/run-mirror.sh', + command => '/usr/local/bin/run-mirror.sh', require => File['/usr/local/mirror_scripts/run-mirror.sh'], } + cron { 'update_pypi_mirror': + user => 'mirror', + hour => '0', + command => '/usr/local/bin/run-mirror.sh', + require => File['/usr/local/bin/run-mirror.sh'], + } + # Rotate the mirror log file include logrotate @@ -109,7 +100,7 @@ class pypimirror( apache::vhost { $vhost_name: port => 80, - docroot => $mirror_file_path, + docroot => $mirror_root, priority => 50, } } diff --git a/modules/pypimirror/templates/run-mirror.sh.erb b/modules/pypimirror/templates/run-mirror.sh.erb index d19aa03889..908acd3378 100644 --- a/modules/pypimirror/templates/run-mirror.sh.erb +++ b/modules/pypimirror/templates/run-mirror.sh.erb @@ -2,9 +2,4 @@ # This file is managed by puppet. # https://github.com/openstack-infra/config -export PIP_DOWNLOAD_CACHE=<%= pip_cache %> -export PIP_TEMP_DOWNLOAD=<%= pip_download %> -export MIRROR_FILE_PATH=<%= mirror_file_path %> -export LOG_FILENAME=<%= log_filename %> -/usr/local/bin/run-mirror <%= git_source %> >>$LOG_FILENAME -/usr/local/bin/process-cache ${PIP_DOWNLOAD_CACHE} ${MIRROR_FILE_PATH} +/usr/local/bin/run-mirror -c <%= mirror_config %> >> <%= log_filename %>