Project

Profile

Help

Issue #4990

Updated by kersom over 5 years ago

It is not stated in the docs that Ansible-collections Ansible-colletions supports lazy sync. 

 However I was able to sync a remote with lazy sync policy. We need either raise an exception if this is not supported or update the docs. 


 Steps: 

 <pre> 
 git clone https://github.com/pulp/pulp_ansible.git 
 cd pulp_ansible/docs/_scripts/ 
 source base.sh 

 http POST $BASE_ADDR/pulp/api/v3/repositories/ name=foo 

 export REPO_HREF=$(http $BASE_ADDR/pulp/api/v3/repositories/ | \ 
   jq -r '.results[] | select(.name == "foo") | ._href') 

 http $BASE_ADDR$REPO_HREF 


 http POST $BASE_ADDR/pulp/api/v3/remotes/ansible/collection/ \ 
     name='bar' \ 
     url='https://galaxy-dev.ansible.com' \ 
     whitelist='testing.ansible_testing_content' \ 
     policy='streamed' 

 export REMOTE_HREF=$(http $BASE_ADDR/pulp/api/v3/remotes/ansible/collection/ | jq -r '.results[] | select(.name == "bar") | ._href') 

 http $BASE_ADDR$REMOTE_HREF 

 export TASK_URL=$(http POST $BASE_ADDR$REMOTE_HREF'sync/' repository=$REPO_HREF \ 
   | jq -r '.task') 

 wait_for_pulp $TASK_URL 
 export REPOVERSION_HREF=${CREATED_RESOURCE[0]} 

 http $BASE_ADDR$REPOVERSION_HREF 
 </pre> 

 outputs: 

 <pre> 
 root@localhost _scripts]# http POST $BASE_ADDR/pulp/api/v3/remotes/ansible/collection/ \ 
 >       name='bar' \ 
 >       url='https://galaxy-dev.ansible.com' \ 
 >       whitelist='testing.ansible_testing_content' \ 
 >       policy='streamed' 
 HTTP/1.1 201 Created 
 Allow: GET, POST, HEAD, OPTIONS 
 Connection: close 
 Content-Length: 482 
 Content-Type: application/json 
 Date: Wed, 12 Jun 2019 18:00:06 GMT 
 Location: /pulp/api/v3/remotes/ansible/collection/a1df15b4-5438-426a-9ca8-051fec031877/ 
 Server: gunicorn/19.9.0 
 Vary: Accept, Cookie 
 X-Frame-Options: SAMEORIGIN 

 { 
     "_created": "2019-06-12T18:00:06.632076Z",  
     "_href": "/pulp/api/v3/remotes/ansible/collection/a1df15b4-5438-426a-9ca8-051fec031877/",  
     "_last_updated": "2019-06-12T18:00:06.632096Z",  
     "_type": "ansible.collection",  
     "download_concurrency": 20,  
     "name": "bar",  
     "policy": "streamed",  
     "proxy_url": null,  
     "ssl_ca_certificate": null,  
     "ssl_client_certificate": null,  
     "ssl_client_key": null,  
     "ssl_validation": true,  
     "url": "https://galaxy-dev.ansible.com",  
     "validate": true,  
     "whitelist": "testing.ansible_testing_content" 
 } 
 root@localhost _scripts]# http $BASE_ADDR$REMOTE_HREF 
 HTTP/1.1 200 OK 
 Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS 
 Connection: close 
 Content-Length: 482 
 Content-Type: application/json 
 Date: Wed, 12 Jun 2019 18:00:43 GMT 
 Server: gunicorn/19.9.0 
 Vary: Accept, Cookie 
 X-Frame-Options: SAMEORIGIN 

 { 
     "_created": "2019-06-12T18:00:06.632076Z",  
     "_href": "/pulp/api/v3/remotes/ansible/collection/a1df15b4-5438-426a-9ca8-051fec031877/",  
     "_last_updated": "2019-06-12T18:00:06.632096Z",  
     "_type": "ansible.collection",  
     "download_concurrency": 20,  
     "name": "bar",  
     "policy": "streamed",  
     "proxy_url": null,  
     "ssl_ca_certificate": null,  
     "ssl_client_certificate": null,  
     "ssl_client_key": null,  
     "ssl_validation": true,  
     "url": "https://galaxy-dev.ansible.com",  
     "validate": true,  
     "whitelist": "testing.ansible_testing_content" 
 } 

 [root@localhost _scripts]# export TASK_URL=$(http POST $BASE_ADDR$REMOTE_HREF'sync/' repository=$REPO_HREF \ 
 >     | jq -r '.task') 
 [root@localhost _scripts]# wait_for_pulp $TASK_URL 
 [root@localhost _scripts]# export REPOVERSION_HREF=${CREATED_RESOURCE[0]} 
 [root@localhost _scripts]# http $BASE_ADDR$REPOVERSION_HREF 
 HTTP/1.1 200 OK 
 Allow: GET, DELETE, HEAD, OPTIONS 
 Connection: close 
 Content-Length: 575 
 Content-Type: application/json 
 Date: Wed, 12 Jun 2019 18:01:50 GMT 
 Server: gunicorn/19.9.0 
 Vary: Accept, Cookie 
 X-Frame-Options: SAMEORIGIN 

 { 
     "_created": "2019-06-12T18:01:35.431134Z",  
     "_href": "/pulp/api/v3/repositories/63cf03b0-109d-4326-b7c9-6f86614ada6d/versions/1/",  
     "base_version": null,  
     "content_summary": { 
         "added": { 
             "ansible.collection": { 
                 "count": 1,  
                 "href": "/pulp/api/v3/content/ansible/collections/?repository_version_added=/pulp/api/v3/repositories/63cf03b0-109d-4326-b7c9-6f86614ada6d/versions/1/" 
             } 
         },  
         "present": { 
             "ansible.collection": { 
                 "count": 1,  
                 "href": "/pulp/api/v3/content/ansible/collections/?repository_version=/pulp/api/v3/repositories/63cf03b0-109d-4326-b7c9-6f86614ada6d/versions/1/" 
             } 
         },  
         "removed": {} 
     },  
     "number": 1 
 } 

 </pre> 

 Pulp installation from source - June/18 
 <pre> 
 (pulp) [root@localhost pulp]# pip list | grep pulp 
 pulp-ansible                      0.2.0b1.dev0  
 pulp-certguard                    0.1.0rc1      
 pulp-docker                       4.0.0b5.dev0  
 pulp-file                         0.1.0b1.dev0  
 pulp-rpm                          3.0.0b4.dev0  
 pulpcore                          3.0.0rc3.dev0 
 pulpcore-plugin                   0.1.0rc3.dev0 

 </pre>

Back