### Summary

The first execution of ```lookup('ansible.builtin.password', 'password.txt encrypt=bcrypt')``` creates the text file.

The second execution fail with ```An unhandled exception occurred while running the lookup plugin 'ansible.builtin.password'. Error was a <class 'ValueError'>, original message: invalid characters in bcrypt salt. invalid characters in bcrypt salt```.

### Issue Type

Bug Report

### Component Name

ansible.builtin.password

### Ansible Version

```console
$ ansible --version
ansible [core 2.14.3]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/eagle/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.10/site-packages/ansible
  ansible collection location = /home/eagle/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.10 (main, Mar  5 2023, 22:26:53) [GCC 12.2.1 20230201] (/usr/bin/python)
  jinja version = 3.1.2
  libyaml = True
```


### Configuration

```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = /etc/ansible/ansible.cfg
```


### OS / Environment

Arch Linux

### Steps to Reproduce

Run the following command 2 times:
```shell
ansible -m debug -a "msg={{lookup('ansible.builtin.password', 'password.txt encrypt=bcrypt') }}" localhost
```
Example output:
```shell
$ ansible -m debug -a "msg={{lookup('ansible.builtin.password', 'password.txt encrypt=bcrypt') }}" localhost
[WARNING]: No inventory was parsed, only implicit localhost is available
localhost | SUCCESS => {
    "msg": "$2b$12$UYPgwPMJVaBFMU9ext22n.LxxvQFDFNYvLWshdEC7jRkSPTu1.VyK"
}

$ cat password.txt
z2fH1h5k.J1Oy6phsP73 salt=UYPgwPMJVaBFMU9ext22n/ ident=2b

$ ansible -m debug -a "msg={{lookup('ansible.builtin.password', 'password.txt encrypt=bcrypt') }}" localhost
[WARNING]: No inventory was parsed, only implicit localhost is available
localhost | FAILED! => {
    "msg": "An unhandled exception occurred while running the lookup plugin 'ansible.builtin.password'. Error was a <class 'ValueError'>, original message: invalid characters in bcrypt salt. invalid characters in bcrypt salt"
}

$ cat password.txt
z2fH1h5k.J1Oy6phsP73 salt=UYPgwPMJVaBFMU9ext22n/ ident=2b ident=2b
```

### Expected Results

The second run should works.

### Actual Results

```console
$ ansible -m debug -a "msg={{lookup('ansible.builtin.password', 'password.txt encrypt=bcrypt') }}" localhost -vvvv
ansible [core 2.14.3]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/eagle/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.10/site-packages/ansible
  ansible collection location = /home/eagle/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.10 (main, Mar  5 2023, 22:26:53) [GCC 12.2.1 20230201] (/usr/bin/python)
  jinja version = 3.1.2
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
yaml declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
ini declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
toml declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
[WARNING]: No inventory was parsed, only implicit localhost is available
Loading callback plugin minimal of type stdout, v2.0 from /usr/lib/python3.10/site-packages/ansible/plugins/callback/minimal.py
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
exception during Jinja2 execution: Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/ansible/template/__init__.py", line 831, in _lookup
    ran = instance.run(loop_terms, variables=self._available_variables, **kwargs)
  File "/usr/lib/python3.10/site-packages/ansible/plugins/lookup/password.py", line 384, in run
    password = do_encrypt(plaintext_password, encrypt, salt=salt, ident=ident)
  File "/usr/lib/python3.10/site-packages/ansible/utils/encrypt.py", line 272, in do_encrypt
    return passlib_or_crypt(result, encrypt, salt_size=salt_size, salt=salt, ident=ident)
  File "/usr/lib/python3.10/site-packages/ansible/utils/encrypt.py", line 265, in passlib_or_crypt
    return PasslibHash(algorithm).hash(secret, salt=salt, salt_size=salt_size, rounds=rounds, ident=ident)
  File "/usr/lib/python3.10/site-packages/ansible/utils/encrypt.py", line 191, in hash
    return self._hash(secret, salt=salt, salt_size=salt_size, rounds=rounds, ident=ident)
  File "/usr/lib/python3.10/site-packages/ansible/utils/encrypt.py", line 244, in _hash
    result = self.crypt_algo.using(**settings).hash(secret)
  File "/usr/lib/python3.10/site-packages/passlib/utils/handlers.py", line 455, in using
    subcls = super(TruncateMixin, cls).using(**kwds)
  File "/usr/lib/python3.10/site-packages/passlib/utils/handlers.py", line 1137, in using
    subcls = super(HasManyIdents, cls).using(**kwds)
  File "/usr/lib/python3.10/site-packages/passlib/utils/handlers.py", line 1653, in using
    subcls = super(HasRounds, cls).using(**kwds)
  File "/usr/lib/python3.10/site-packages/passlib/utils/handlers.py", line 1350, in using
    salt = subcls._norm_salt(salt, relaxed=relaxed)
  File "/usr/lib/python3.10/site-packages/passlib/handlers/bcrypt.py", line 237, in _norm_salt
    salt = super(_BcryptCommon, cls)._norm_salt(salt, **kwds)
  File "/usr/lib/python3.10/site-packages/passlib/utils/handlers.py", line 1459, in _norm_salt
    raise ValueError("invalid characters in %s salt" % cls.name)
ValueError: invalid characters in bcrypt salt
localhost | FAILED! => {
    "msg": "An unhandled exception occurred while running the lookup plugin 'ansible.builtin.password'. Error was a <class 'ValueError'>, original message: invalid characters in bcrypt salt. invalid characters in bcrypt salt"
}
```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct
"""Format the password and salt for saving
    :arg password: the plaintext password to save
    :arg salt: the salt to use when encrypting a password
    :arg encrypt: Which method the user requests that this password is encrypted.
        Note that the password is saved in clear.  Encrypt just tells us if we
        must save the salt value for idempotence.  Defaults to None.
    :arg ident: Which version of BCrypt algorithm to be used.
        Valid only if value of encrypt is bcrypt.
        Defaults to None.
    :returns: a text string containing the formatted information
    .. warning:: Passwords are saved in clear.  This is because the playbooks
        expect to get cleartext passwords from this lookup.
    """
    if not encrypt and not salt:
        return password
    
    if not salt:
        raise AnsibleAssertionError('_format_content was called with encryption requested but no salt value')
    if ident:
        return u'%s salt=%s ident=%s' % (password, salt, ident)
    return u'%s salt=%s' % (password, salt)
def _write_password_file(b_path, content):
    b_pathdir = os.path.dirname(b_path)
    makedirs_safe(b_pathdir, mode=0o700)
    with open(b_path, 'wb') as f:
        os.chmod(b_path, 0o600)
        b_content = to_bytes(content, errors='surrogate_or_strict') + b'\n'
        f.write(b_content)
def _get_lock(b_path):