Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Creating alias for setting minio
Browse files Browse the repository at this point in the history
  • Loading branch information
fao89 committed Mar 3, 2020
1 parent 0ae0651 commit 6b28ccb
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
10 changes: 10 additions & 0 deletions roles/pulp-devel/tasks/install_basic_packages.yml
Expand Up @@ -23,6 +23,7 @@
- name: Install Centos Specific Packages
package:
name:
- nc
- python-virtualenvwrapper
- ruby-devel
retries: "{{ pulp_devel_package_retries }}"
Expand All @@ -36,6 +37,7 @@
- bash-completion
- fd-find
- fzf
- netcat
- python3-setuptools
- virtualenvwrapper
- ripgrep
Expand All @@ -55,6 +57,7 @@
- dnf-utils
- fd-find
- fzf
- nc
- python-django-bash-completion
- python3-setuptools
- python3-virtualenvwrapper
Expand All @@ -66,4 +69,11 @@
register: result
until: result is succeeded
when: ansible_distribution == 'Fedora'

- name: Install Minio Client
get_url:
url: https://dl.min.io/client/mc/release/linux-amd64/mc
dest: /usr/local/bin
owner: '{{ developer_user }}'
mode: 0750
...
7 changes: 7 additions & 0 deletions roles/pulp-devel/tasks/install_docs_requirements.yml
Expand Up @@ -20,6 +20,13 @@
virtualenv: '{{ pulp_install_dir }}'
virtualenv_command: '{{ pulp_python_interpreter }} -m venv'

- name: Install requirements for S3 tests
pip:
name: django-storages[boto3]
state: present
virtualenv: '{{ pulp_install_dir }}'
virtualenv_command: '{{ pulp_python_interpreter }} -m venv'

- name: Install HTTPie and JWT authentication plugin
pip:
name:
Expand Down
42 changes: 42 additions & 0 deletions roles/pulp-devel/templates/alias.bashrc.j2
Expand Up @@ -212,3 +212,45 @@ pbindings(){
cd $CURRENT_DIR
}
_pbindings_help="Create and install bindings. Example usage: pbindings pulpcore python"

pminio(){
if [ "$1" = 'stop' ]
then
sudo bash -c "sed -i '/AWS_ACCESS_KEY_ID/d' /etc/pulp/settings.py"
sudo bash -c "sed -i '/AWS_SECRET_ACCESS_KEY/d' /etc/pulp/settings.py"
sudo bash -c "sed -i '/AWS_STORAGE_BUCKET_NAME/d' /etc/pulp/settings.py"
sudo bash -c "sed -i '/AWS_DEFAULT_ACL/d' /etc/pulp/settings.py"
sudo bash -c "sed -i '/S3_USE_SIGV4/d' /etc/pulp/settings.py"
sudo bash -c "sed -i '/AWS_S3_SIGNATURE_VERSION/d' /etc/pulp/settings.py"
sudo bash -c "sed -i '/AWS_S3_ADDRESSING_STYLE/d' /etc/pulp/settings.py"
sudo bash -c "sed -i '/AWS_S3_REGION_NAME/d' /etc/pulp/settings.py"
sudo bash -c "sed -i '/DEFAULT_FILE_STORAGE/d' /etc/pulp/settings.py"
sudo bash -c "sed -i '/MEDIA_ROOT/d' /etc/pulp/settings.py"
sudo bash -c "sed -i '/AWS_S3_ENDPOINT_URL/d' /etc/pulp/settings.py"
podman stop pulp_minio
else
export MINIO_ACCESS_KEY=AKIAIT2Z5TDYPX3ARJBA
export MINIO_SECRET_KEY=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
podman run -d -p 9000:9000 --name pulp_minio -e MINIO_ACCESS_KEY=$MINIO_ACCESS_KEY -e MINIO_SECRET_KEY=$MINIO_SECRET_KEY minio/minio server /data
while ! nc -z localhost 9000; do echo 'Wait minio to startup...' && sleep 0.1; done;
mc config host add s3 http://localhost:9000 AKIAIT2Z5TDYPX3ARJBA fqRvjWaPU5o0fCqQuUWbj9Fainj2pVZtBCiDiieS --api S3v4
mc config host rm local
mc mb s3/pulp3 --region eu-central-1
workon pulp
echo "Declaring S3 environment variables..."
sudo bash -c "echo AWS_ACCESS_KEY_ID = \'$MINIO_ACCESS_KEY\' >> /etc/pulp/settings.py"
sudo bash -c "echo AWS_SECRET_ACCESS_KEY = \'$MINIO_SECRET_KEY\' >> /etc/pulp/settings.py"
sudo bash -c "echo AWS_STORAGE_BUCKET_NAME = \'pulp3\' >> /etc/pulp/settings.py"
sudo bash -c "echo AWS_DEFAULT_ACL = None >> /etc/pulp/settings.py"
sudo bash -c "echo S3_USE_SIGV4 = True >> /etc/pulp/settings.py"
sudo bash -c "echo AWS_S3_SIGNATURE_VERSION = \'s3v4\' >> /etc/pulp/settings.py"
sudo bash -c "echo AWS_S3_ADDRESSING_STYLE = \'path\' >> /etc/pulp/settings.py"
sudo bash -c "echo AWS_S3_REGION_NAME = \'eu-central-1\' >> /etc/pulp/settings.py"
sudo bash -c "echo DEFAULT_FILE_STORAGE = \'storages.backends.s3boto3.S3Boto3Storage\' >> /etc/pulp/settings.py"
sudo bash -c "echo MEDIA_ROOT = \'\' >> /etc/pulp/settings.py"
sudo bash -c "echo AWS_S3_ENDPOINT_URL = \'http:\/\/localhost:9000\' >> /etc/pulp/settings.py"
echo "The minio instance has been setup. It's recommended that you run 'pclean' now."
fi
_paction restart
}
_pminio_help="Switch to minio for S3 testing. For stopping it: pminio stop"

0 comments on commit 6b28ccb

Please sign in to comment.