From 05578db75b89347399834f0dca603038fef3dd63 Mon Sep 17 00:00:00 2001 From: Pavlov Makar Date: Tue, 2 Dec 2025 22:18:18 +0300 Subject: [PATCH] Create dirs for repo and add pypiserver service --- roles/rproxy/tasks/dirs.yml | 30 ++++++++++++++++++++ roles/rproxy/tasks/main.yml | 6 +++- roles/rproxy/tasks/pypi.yml | 17 +++++++++++ roles/rproxy/templates/pypiserver.service.j2 | 17 +++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 roles/rproxy/tasks/pypi.yml create mode 100644 roles/rproxy/templates/pypiserver.service.j2 diff --git a/roles/rproxy/tasks/dirs.yml b/roles/rproxy/tasks/dirs.yml index dffb35d..8f8752e 100644 --- a/roles/rproxy/tasks/dirs.yml +++ b/roles/rproxy/tasks/dirs.yml @@ -14,6 +14,36 @@ path: "{{ repo_data_dir }}" state: directory +- name: "Create {{ repo_data_dir }}/archive" + ansible.builtin.file: + path: "{{ repo_data_dir }}/archive" + state: directory + +- name: "Create {{ repo_data_dir }}/pip" + ansible.builtin.file: + path: "{{ repo_data_dir }}/pip" + state: directory + +- name: "Create {{ repo_data_dir }}/pip/py3" + ansible.builtin.file: + path: "{{ repo_data_dir }}/pip/py3" + state: directory + +- name: "Create {{ repo_data_dir }}/repo" + ansible.builtin.file: + path: "{{ repo_data_dir }}/repo" + state: directory + +- name: "Create {{ repo_data_dir }}/repo/almalinux" + ansible.builtin.file: + path: "{{ repo_data_dir }}/repo/almalinux" + state: directory + +- name: "Create {{ repo_data_dir }}/repo/almalinux/10" + ansible.builtin.file: + path: "{{ repo_data_dir }}/repo/almalinux/10" + state: directory + - name: Create sites dir ansible.builtin.file: path: "{{ rproxy_dir }}/sites" diff --git a/roles/rproxy/tasks/main.yml b/roles/rproxy/tasks/main.yml index 701c44c..d1bfbb3 100644 --- a/roles/rproxy/tasks/main.yml +++ b/roles/rproxy/tasks/main.yml @@ -17,4 +17,8 @@ - name: Repository install ansible.builtin.include_tasks: - file: repo.yml \ No newline at end of file + file: repo.yml + +- name: Pypi repository install + ansible.builtin.include_tasks: + file: pypi.yml \ No newline at end of file diff --git a/roles/rproxy/tasks/pypi.yml b/roles/rproxy/tasks/pypi.yml new file mode 100644 index 0000000..61c81f8 --- /dev/null +++ b/roles/rproxy/tasks/pypi.yml @@ -0,0 +1,17 @@ +--- +- name: Install pypi-server + ansible.builtin.pip: + name: + - pypiserver + +- name: Copy pypi-server service file + ansible.builtin.template: + src: "templates/pypiserver.service.j2" + dest: "/etc/systemd/system/pypiserver.service" + +- name: Enable pypiserver service + ansible.builtin.systemd: + name: "pypiserver.service" + state: started + enabled: yes + daemon_reload: yes \ No newline at end of file diff --git a/roles/rproxy/templates/pypiserver.service.j2 b/roles/rproxy/templates/pypiserver.service.j2 new file mode 100644 index 0000000..e79ca9d --- /dev/null +++ b/roles/rproxy/templates/pypiserver.service.j2 @@ -0,0 +1,17 @@ +[Unit] +Description=PyPI Server (pypiserver) +After=network.target +Wants=network.target + +[Service] +Type=simple +WorkingDirectory={{ repo_data_dir }}/pip/py3 +ExecStart=/usr/bin/python3 -m pypiserver -p 10000 -o {{ repo_data_dir }}/pip/py3 +Restart=always +RestartSec=5 +StandardOutput=journal +StandardError=journal +ReadWriteDirectories={{ repo_data_dir }}/pip/py3 + +[Install] +WantedBy=multi-user.target