Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(git_clone): change ownership on copy #62

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hairmare
Copy link
Member

@hairmare hairmare commented Jan 9, 2025

No description provided.

Copy link
Member

@smirta smirta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming this is verified to work, lgtm. We'd need to adjust https://github.com/radiorabe/ansible-collection-rabe_foreman/blob/main/roles/foreman/tasks/host_groups.yaml in that case.

@hairmare
Copy link
Member Author

I took this for a spin locally and now need to figure out why it's complaining:

Unsupported parameters for (ansible.builtin.git) module: group, owner. Supported parameters include: accept_hostkey, accept_newhostkey, archive, archive_prefix, bare, clone, depth, dest, executable, force, gpg_whitelist, key_file, recursive, reference, refspec, remote, repo, separate_git_dir, single_branch, ssh_opts, track_submodules, umask, update, verify_commit, version (name).

i'm pretty sure the description was copy-pasta from the docs... looking back, i'm not sure from where.

@hairmare
Copy link
Member Author

🤔 ansible/ansible#51601

@hairmare
Copy link
Member Author

hairmare commented Jan 13, 2025

I kinda works with this play:

---
- name: Play
  hosts: [localhost]
  roles:
    - role: git_clone
      vars:
        radiorabe_git_clone:
          - repo: [email protected]:radiorabe/ansible-collection-common.git
            dest: /tmp/checkout
            single_branch: yes
            version: main
        radiorabe_git_local_clone: true
        radiorabe_git_clone_remote_owner: hairmare
        radiorabe_git_clone_remote_group: testgroup
        radiorabe_git_clone_remote_dest: "/tmp/dest"

It's awfully slow because it copies the .git folder and does a chown on each individual file.

$ ansible-playbook play.yaml
 _____________
< PLAY [Play] >
 -------------
   \
    \
      _____   _________
     /     \_/         |
    |                 ||
    |                 ||
   |    ###\  /###   | |
   |     0  \/  0    | |
  /|                 | |
 / |        <        |\ \
| /|                 | | |
| |     \_______/   |  | |
| |                 | / /
/||                 /|||
   ----------------|
        | |    | |
        ***    ***
       /___\  /___\

 ________________________
< TASK [Gathering Facts] >
 ------------------------
       \    ____
        \  /    \
          | ^__^ |
          | (oo) |______
          | (__) |      )\/\
           \____/|----w |
                ||     ||

                 Moofasa

ok: [localhost]
 _______________________________________________________
/ TASK [git_clone : RaBe Common : git_clone : Clone git \
\ repository locally]                                   /
 -------------------------------------------------------
 \     ____________
  \    |__________|
      /           /\
     /           /  \
    /___________/___/|
    |          |     |
    |  ==\ /== |     |
    |   O   O  | \ \ |
    |     <    |  \ \|
   /|          |   \ \
  / |  \_____/ |   / /
 / /|          |  / /|
/||\|          | /||\/
    -------------|
        | |    | |
       <__/    \__>

[WARNING]: Using a variable for a task's 'args' is unsafe in some situations (see https://docs.ansible.com/ansible/devel/reference_appendices/faq.html#argsplat-unsafe)
ok: [localhost -> 127.0.0.1] => (item={'repo': '[email protected]:radiorabe/ansible-collection-common.git', 'dest': '/tmp/checkout', 'single_branch': True, 'version': 'main'})
 ___________________________________________________________
/ TASK [git_clone : RaBe Common : git_clone : Copy files to \
\ remote]                                                   /
 -----------------------------------------------------------
  \
   \   \_\_    _/_/
    \      \__/
           (oo)\_______
           (__)\       )\/\
               ||----w |
               ||     ||

changed: [localhost] => (item={'repo': '[email protected]:radiorabe/ansible-collection-common.git', 'dest': '/tmp/checkout', 'single_branch': True, 'version': 'main'})
 ____________
< PLAY RECAP >
 ------------
    \
     \
                                   .::!!!!!!!:.
  .!!!!!:.                        .:!!!!!!!!!!!!
  ~~~~!!!!!!.                 .:!!!!!!!!!UWWW$$$
      :$$NWX!!:           .:!!!!!!XUWW$$$$$$$$$P
      $$$$$##WX!:      .<!!!!UW$$$$"  $$$$$$$$#
      $$$$$  $$$UX   :!!UW$$$$$$$$$   4$$$$$*
      ^$$$B  $$$$\     $$$$$$$$$$$$   d$$R"
        "*$bd$$$$      '*$$$$$$$$$$$o+#"
             """"          """""""

localhost                  : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

$ ls -al /tmp/checkout/
total 52
drwxr-xr-x.  6 hairmare hairmare   220 13. Jan 18:43 .
drwxrwxrwt. 28 root     root       660 13. Jan 18:48 ..
-rw-r--r--.  1 hairmare hairmare   740 13. Jan 18:43 .ansible-lint-ignore
-rw-r--r--.  1 hairmare hairmare   111 13. Jan 18:43 .ansible-lint.yml
-rw-r--r--.  1 hairmare hairmare   579 13. Jan 18:43 galaxy.yml
drwxr-xr-x.  8 hairmare hairmare   300 13. Jan 18:46 .git
drwxr-xr-x.  3 hairmare hairmare    80 13. Jan 18:43 .github
-rw-r--r--.  1 hairmare hairmare 34520 13. Jan 18:43 LICENSE
drwxr-xr-x.  2 hairmare hairmare    60 13. Jan 18:43 meta
-rw-r--r--.  1 hairmare hairmare   986 13. Jan 18:43 README.md
drwxr-xr-x.  8 hairmare hairmare   160 13. Jan 18:43 roles
$ ls -al /tmp/dest/
total 52
drwxr-xr-x.  6 hairmare testgroup   220 13. Jan 18:44 .
drwxrwxrwt. 27 root     root        640 13. Jan 18:48 ..
-rw-r--r--.  1 hairmare testgroup   740 13. Jan 18:43 .ansible-lint-ignore
-rw-r--r--.  1 hairmare testgroup   111 13. Jan 18:43 .ansible-lint.yml
-rw-r--r--.  1 hairmare testgroup   579 13. Jan 18:43 galaxy.yml
drwxr-xr-x.  7 hairmare testgroup   280 13. Jan 18:46 .git
drwxr-xr-x.  3 hairmare testgroup    80 13. Jan 18:44 .github
-rw-r--r--.  1 hairmare testgroup 34520 13. Jan 18:43 LICENSE
drwxr-xr-x.  2 hairmare testgroup    60 13. Jan 18:44 meta
-rw-r--r--.  1 hairmare testgroup   986 13. Jan 18:43 README.md
drwxr-xr-x.  6 hairmare testgroup   120 13. Jan 18:44 roles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants