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

new module: filesize, create or resize a file, given its size #148

Closed
wants to merge 5 commits into from

Conversation

quidame
Copy link
Contributor

@quidame quidame commented Mar 6, 2021

SUMMARY

New module filesize to create a file or resize it. This is a simple wrapper around dd that allows to grow or reduce (truncate) a file to any arbitrary size. Useful to manage swap files.

Supports check_mode and diff.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

filesize

ADDITIONAL INFORMATION

Example:

- name: create/resize a swap file
  filesize:
    path: /var/swap
    size: 2G
    mode: u=rw,go=
    group: root
    owner: root
  become: yes
  diff: yes

@quidame
Copy link
Contributor Author

quidame commented Mar 16, 2021

Ansible Zuul check ansible-changelog-fragment fails due to

2021-03-16 20:05:43.117394 | TASK [Changelog fragment failed]
2021-03-16 20:05:43.197785 | localhost | ERROR
2021-03-16 20:05:43.198122 | localhost | {
2021-03-16 20:05:43.198195 | localhost |   "msg": "Your pull-request is missing a changelog fragment, please add one. It should explain to end users the reason for your change."
2021-03-16 20:05:43.198261 | localhost | }

Does a new module need a changelog fragment ? If yes, what could be a valid changelog fragment entry ?

---
new_modules:
  - module_name - short description (PR URL)

thanks for help

@quidame
Copy link
Contributor Author

quidame commented Mar 16, 2021

Ansible Zuul check ansible-test-sanity-docker fails against other modules than this one, and it also seems to be false positives (at least for the mount module, since passno has nothing to do with a password or any kind of secret):

2021-03-16 20:27:04.127992 | centos-8 | ERROR: Found 3 validate-modules issue(s) which need to be resolved:
2021-03-16 20:27:04.128105 | centos-8 | ERROR: plugins/modules/authorized_key.py:0:0: no-log-needed: Argument 'key' in argument_spec could be a secret, though doesn't have `no_log` set
2021-03-16 20:27:04.128204 | centos-8 | ERROR: plugins/modules/authorized_key.py:0:0: no-log-needed: Argument 'key_options' in argument_spec could be a secret, though doesn't have `no_log` set
2021-03-16 20:27:04.128303 | centos-8 | ERROR: plugins/modules/mount.py:0:0: no-log-needed: Argument 'passno' in argument_spec could be a secret, though doesn't have `no_log` set

This issue is addressed by this targeted PR now: #156

Copy link
Contributor

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

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

@quidame , hi, though I'm not a specialist in this area but it looks like a great job:)

plugins/modules/filesize.py Outdated Show resolved Hide resolved
plugins/modules/filesize.py Outdated Show resolved Hide resolved
plugins/modules/filesize.py Outdated Show resolved Hide resolved
plugins/modules/filesize.py Outdated Show resolved Hide resolved
plugins/modules/filesize.py Show resolved Hide resolved
plugins/modules/filesize.py Outdated Show resolved Hide resolved
plugins/modules/filesize.py Show resolved Hide resolved
plugins/modules/filesize.py Outdated Show resolved Hide resolved
@Andersson007
Copy link
Contributor

Andersson007 commented Mar 17, 2021

@quidame update about changelog fragments - I've just noticed that the collection require it.
create a fragment with an entry of type trivial:. It will be ignored when building release notes but will allow to pass the check

trivial:
- filesize - new module to create or resize a file (https://github.com/ansible-collections/ansible.posix/pull/148).

@Andersson007
Copy link
Contributor

Andersson007 commented Mar 17, 2021

Also i can see sanity issues:

2021-03-16 22:23:06.394805 | centos-8 | ERROR: Found 3 validate-modules issue(s) which need to be resolved:
2021-03-16 22:23:06.395046 | centos-8 | ERROR: plugins/modules/authorized_key.py:0:0: no-log-needed: Argument 'key' in argument_spec could be a secret, though doesn't have `no_log` set
2021-03-16 22:23:06.395276 | centos-8 | ERROR: plugins/modules/authorized_key.py:0:0: no-log-needed: Argument 'key_options' in argument_spec could be a secret, though doesn't have `no_log` set
2021-03-16 22:23:06.395490 | centos-8 | ERROR: plugins/modules/mount.py:0:0: no-log-needed: Argument 'passno' in argument_spec could be a secret, though doesn't have `no_log` set

It's not about your module. Ignore it.

@Andersson007
Copy link
Contributor

@quidame once it's ready for review, please let me know, I'll try to ping other folks

@Andersson007
Copy link
Contributor

I've just pinged the other engineers.

@quidame
Copy link
Contributor Author

quidame commented Mar 19, 2021

@Andersson007 yeah ! thanks

@Andersson007
Copy link
Contributor

recheck

@Andersson007
Copy link
Contributor

@quidame there's only the changelog issue left. Please do what you did to get rid of it:)

quidame and others added 5 commits March 24, 2021 19:57
* description: create a file given its size, or resize it
* add integration tests (filter Mac OS X < 11 for some of them)
Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
* Add a stat task for almost every filesize tasks and check results
  (size) consistency.
* Check that cmd result is always the same, in check mode or not.
* Check consistency of other returned results (size_diff & filesize.bytes).

add DOCUMENTATION.seealso section
fix docstrings coding style (tenses, typos...)
add changelog fragment (placeholder)
@quidame
Copy link
Contributor Author

quidame commented Mar 25, 2021

@Andersson007 , done :)

@Andersson007
Copy link
Contributor

@quidame thanks, I pinged folks in IRC that it's ready for review

Copy link
Contributor

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

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

LGTM (the idea, documentation formatting, tests, and other general things). Though I'm not an expert.

@Andersson007
Copy link
Contributor

@quidame also FYI - this collection is officially supported and available on Automation hub, so the barrier to get new stuff merged here is much higher than, say, in c.g., resp. time between "ts created" and "ts merged" can be much longer as well.

I suggest waiting for some time and, if it doesn't get merged during April, we could move it to community.general.
What do you think?

@quidame
Copy link
Contributor Author

quidame commented Mar 26, 2021

@Andersson007 , thanks for the review !

I suggest waiting for some time and, if it doesn't get merged during April, we could move it to community.general.
What do you think?

Sounds good to me.

@Andersson007
Copy link
Contributor

@quidame hi, it's still not the end of the month but we've discuss with @felixfontein that the PR content could be moved to community.general and it seems to be fine. If you're ok with it, feel free to move now or wait until May (which, IMO, doesn't make a lot of sense). What do you think?

@quidame
Copy link
Contributor Author

quidame commented Apr 13, 2021

@Andersson007 @felixfontein OK, moved to ansible-collections/community.general#2232.
I close this one.

@quidame quidame closed this Apr 13, 2021
@Andersson007
Copy link
Contributor

@quidame great, thanks!

@quidame quidame deleted the new_module/filesize branch April 13, 2021 12:05
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