Re: [ansible-project] Re: vmware_guest does not add cd-rom for a VM

2022-05-12 Thread Dick Visser



On 2022-05-12 (Thu) 19:13, Anil Kumar wrote:

Is this bug?


Yes, but probably one in your own configuration:


On Thursday, May 12, 2022 at 5:19:55 PM UTC+2 Anil Kumar wrote:

here is my code

- hosts: localhost
   connection: localhost
   vars:
    vcenter_hostname: myVcenter
    vcenter_username: **
    vcenter_password: '**'
   tasks:
   - name: Create a virtual machine from a template
     vmware_guest:
       hostname: "{{ vcenter_hostname }}"
       username: "{{ vcenter_username }}"
       password: "{{ vcenter_password }}"
       validate_certs: no
       folder: /RHEL
       name: mtest
       state: poweredon
       #template: template_el7
       cdrom:
        - controller_number: 0
          controller_type: sata


You define type as sata, but the ansible version that you run only 
supports 'ide':


https://docs.ansible.com/ansible/2.9/modules/vmware_guest_module.html#parameter-cdrom


Try upgrading to something less ancient, or use 'ide', or don't define 
controller_type as 'ide' is the default for that anyway.



Dick

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/110640df-8217-c87c-90b6-db1cbc1884ad%40gmail.com.


OpenPGP_0x266713D4E6EF488D.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Playbook structure

2022-05-12 Thread Dick Visser



On 2022-05-10 (Tue) 08:30, Dick Visser wrote:

stylistic nit pick


  tasks:
  ⦙ - name: install ansible dependencies
  ⦙ ⦙ apt:
  ⦙ ⦙ ⦙ name: ['python3', 'python3-apt']
  ⦙ ⦙ ⦙ state: present


  - name: install ansible dependencies
apt:
name:
 - python3
 - python3-apt
   state: present

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/219d7934-96a6-fe5e-ad8c-f844dfa041b4%40gmail.com.


OpenPGP_0x266713D4E6EF488D.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


[ansible-project] Re: vmware_guest does not add cd-rom for a VM

2022-05-12 Thread Anil Kumar
Is this bug?

On Thursday, May 12, 2022 at 5:19:55 PM UTC+2 Anil Kumar wrote:

> here is my code
>
> - hosts: localhost
>   connection: localhost
>   vars:
>vcenter_hostname: myVcenter
>vcenter_username: **
>vcenter_password: '**'
>   tasks:
>   - name: Create a virtual machine from a template
> vmware_guest:
>   hostname: "{{ vcenter_hostname }}"
>   username: "{{ vcenter_username }}"
>   password: "{{ vcenter_password }}"
>   validate_certs: no
>   folder: /RHEL
>   name: mtest
>   state: poweredon
>   #template: template_el7
>   cdrom:
>- controller_number: 0
>  controller_type: sata
>  unit_number: 0
>  type: client
>  state: present
> delegate_to: localhost
>
> ===
> $ ansible --version
> ansible 2.9.1
>   config file = /etc/ansible/ansible.cfg
>   configured module search path = 
> [u'/home/athangal/.ansible/plugins/modules', 
> u'/usr/share/ansible/plugins/modules']
>   ansible python module location = /usr/lib/python2.7/site-packages/ansible
>   executable location = /usr/bin/ansible
>   python version = 2.7.5 (default, Aug 13 2020, 02:51:10) [GCC 4.8.5 
> 20150623 (Red Hat 4.8.5-39)]
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/af2abd7f-09d7-4b6f-9496-39583b9ba77cn%40googlegroups.com.


RE: [EXTERNAL] Re: [ansible-project] trying to modify line in yaml file spaces

2022-05-12 Thread 'Hearn, Stan J.' via Ansible Project
I agree that it would better to manage state not contents of the file.

I suggest having multiple docker compose files each pointing to the jenkins 
version and use Ansible to change symbolic links to the one you desire.

A list of files would be
docker-compose-jenkins:2.232.1
docker-compose-jenkins:2.303.1
docker-compose-jenkins:2.303.2
docker-compose-jenkins:2.319.2
docker-compose-jenkins:2.319.3
docker-compose-jenkins:2.332.1

Ansible would set the symlink to the desired docker-compose

Sym Link -- docker-compose.yml -> docker-compose-jenkins:2.332.1

-Original Message-
From: ansible-project@googlegroups.com  On 
Behalf Of Dick Visser
Sent: Wednesday, May 11, 2022 2:39 PM
To: ansible-project@googlegroups.com
Subject: [EXTERNAL] Re: [ansible-project] trying to modify line in yaml file 
spaces

You're apparently trying to keep some sort of record/audit trail of
used software versions, as comments in a docker compose yaml file.
While it will probably be possible to do what you want, the question
is: should you?
IMHO this is pretty much the opposite of what ansible was meant for...
Why not set up something better?

I can't speak for others but personally I'm not very inclined to help
with questions about such kludges.
In that respect it is also in your own interest to put the bar a
little bit higher...



On Wed, 11 May 2022 at 20:17, Tony Wong  wrote:
>
> trying to modify this line
>
>  image: jenkins/jenkins:2.332.1
>
> # docker-compose.yml
> version: '3.7'
> services:
>   jenkins:
> #image: jenkins/jenkins:lts
> #image: jenkins/jenkins:2.289.3
> #image: jenkins/jenkins:2.303.1
> #image: jenkins/jenkins:2.303.2
> #image: jenkins/jenkins:2.319.2
> #image: jenkins/jenkins:2.319.3
> image: jenkins/jenkins:2.332.1
>
> modify line
>
>  image: jenkins/jenkins:2.332.1
> to
> # image: jenkins/jenkins:2.332.1
>
> and then add
>  image: jenkins/jenkins:2.332.2
>
> but my pb keeps adding it at the end of the file
>
>
> maybe something to do with spaces?
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://urldefense.com/v3/__https://groups.google.com/d/msgid/ansible-project/a9f5ffcb-3a24-426e-90dd-6b4eb214bb6bn*40googlegroups.com__;JQ!!Fto3Xw!oBy446sXvh8vwEHVrUEZ4_x5NxVwcxxOdUTBLg2carCrYRieYcCmd6eK4mXy8r8qhQ6bMmCUFqKLJiGFmQ$
>  .

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://urldefense.com/v3/__https://groups.google.com/d/msgid/ansible-project/CAF8BbLY1X1t1U8cvmijGRnktD4gCpxSD6QXub3oiXQm6Ry-zUg*40mail.gmail.com__;JQ!!Fto3Xw!oBy446sXvh8vwEHVrUEZ4_x5NxVwcxxOdUTBLg2carCrYRieYcCmd6eK4mXy8r8qhQ6bMmCUFqLxFanfNA$
 .

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/PH0PR10MB5593AEAB53475ED64A0DAAB0F0CB9%40PH0PR10MB5593.namprd10.prod.outlook.com.


[ansible-project]

2022-05-12 Thread Tony Wong
When I run this pb, The line keeps getting replaced with this



vars.yml

line_to_replace: "'search: 'image: jenkins/jenkins:2.332.1', replace: 
'#image: jenkins/jenkins:2.332.1''"

main.yml

- name: comment line
lineinfile:
backup: no
backrefs: yes
state: present
path: "{{ file_path }}"
regexp: "{{ exp }}"
line: '\1{{ item.replace }}'
with_items: 
- '{{ line_to_replace }}'

any idea?

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7e9646b6-9dd9-4eae-8bb1-aedd1f32c70dn%40googlegroups.com.


[ansible-project] vmware_guest does not add cd-rom for a VM

2022-05-12 Thread Anil Kumar
here is my code

- hosts: localhost
  connection: localhost
  vars:
   vcenter_hostname: myVcenter
   vcenter_username: **
   vcenter_password: '**'
  tasks:
  - name: Create a virtual machine from a template
vmware_guest:
  hostname: "{{ vcenter_hostname }}"
  username: "{{ vcenter_username }}"
  password: "{{ vcenter_password }}"
  validate_certs: no
  folder: /RHEL
  name: mtest
  state: poweredon
  #template: template_el7
  cdrom:
   - controller_number: 0
 controller_type: sata
 unit_number: 0
 type: client
 state: present
delegate_to: localhost

===
$ ansible --version
ansible 2.9.1
  config file = /etc/ansible/ansible.cfg
  configured module search path = 
[u'/home/athangal/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Aug 13 2020, 02:51:10) [GCC 4.8.5 
20150623 (Red Hat 4.8.5-39)]

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b741f2a1-832e-4616-9332-823c95b9ef97n%40googlegroups.com.


[ansible-project] Re: Why cannot rename directory after unarchiving file in unarchive module

2022-05-12 Thread Алексей Кузнецов
this function very need

On Monday, June 12, 2017 at 4:09:21 PM UTC+3 deso...@gmail.com wrote:

> I want to rename directory after unarchiving file in unarchive module, but 
> there seems no option to do.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8243278d-b42a-4434-b29d-3881f61da91an%40googlegroups.com.


Re: [ansible-project] Playbook structure

2022-05-12 Thread Stefan Hornburg (Racke)

On 12/05/2022 12:57, Marc Haber wrote:

Hi Dirk,

On Tue, May 10, 2022 at 08:30:13AM +0200, Dick Visser wrote:

On 2022-05-09 (Mon) 22:06, Marc Haber wrote:

after using ansible for quite a while, my project to manage my own
servers has grown to a respectable size. I was a puppet user before, so
I have a single big playbook containing everything. I have the feeling
this is like holding ansible wrong, and I also have the feeling that I
have my playbook structured wrong. Judging from the single "name"
setting, I took the wrong turn in the very beginning. The playbook does
what it is intended to do, however.

Here is an excerpt from my playbook.

---
- name: apply common configuration
   hosts: all
   remote_user: zgansible
   become: "yes"


What is the reason for quoting this boolean? It is usually done to force it
to be a string, but AFAIK this parameter requires a boolean.


Historical reasons, fixed. I probably didnt know any better, and it's
still a matter of try-and-err whether to find out whether ansible
wants/insists on things being quoted or not.

[snip]


I don't see anything totally wrong with the above approach.
Perhaps try to avoid the inline lists but that's cosmetics.


How would I write them any better?


In the other news, where would I correctly place (and activate) this handler:

---
- name: apt update
command: "apt-get update"

if I intend to notify this handler from any role that might use the apt
provider to install packages?


What is the use case for this?
If you want to make sure this is always run prior to any package task, then
you should use the update_cache parameters of the apt module:

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html#parameter-update_cache


updating the package lists after fiddling with things in /etc/apt, for
example preparing a release upgrade or adding an external repository
(docker *cough*). Doing an apt update right before any check whether any
required package is already installed seems overkill, but I need to
ponder about that.


You can add/modify/delete the external repo with Ansible and run the apt update 
only when the repo changed.

The equivalent for "apt-get update" is:

- name: Update APT cache
  apt:
update_cache: yes

Regards
   Racke



Greetings
Marc




--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1a200e5e-9c3c-3ab5-84c5-deb494f6f073%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Playbook structure

2022-05-12 Thread Stefan Hornburg (Racke)

On 09/05/2022 22:06, Marc Haber wrote:

Hi,

after using ansible for quite a while, my project to manage my own
servers has grown to a respectable size. I was a puppet user before, so
I have a single big playbook containing everything. I have the feeling
this is like holding ansible wrong, and I also have the feeling that I
have my playbook structured wrong. Judging from the single "name"
setting, I took the wrong turn in the very beginning. The playbook does
what it is intended to do, however.


My two cents:

- host name / remote user should be in the inventory and not in the playbook
- consider using import_role instead of include_role

Regards
   Racke



Here is an excerpt from my playbook.

---
- name: apply common configuration
   hosts: all
   remote_user: zgansible
   become: "yes"
   tasks:
   ⦙ - name: install ansible dependencies
   ⦙ ⦙ apt:
   ⦙ ⦙ ⦙ name: ['python3', 'python3-apt']
   ⦙ ⦙ ⦙ state: present
   ⦙ - name: get package facts
   ⦙ ⦙ package_facts:
   ⦙ ⦙ ⦙ manager: "auto"
   ⦙ ⦙ tags: always
   ⦙ - name: print facts
   ⦙ ⦙ debug:
   ⦙ ⦙ ⦙ var: ansible_facts
   ⦙ ⦙ tags: [never, debug, printfacts]
   ⦙ - name: print package facts
   ⦙ ⦙ debug:
   ⦙ ⦙ ⦙ var: ansible_facts.packages
   ⦙ ⦙ tags: [never, debug, printpackagefacts]
   ⦙ - include_role:
   ⦙ ⦙ ⦙ name: clean-motd
   ⦙ ⦙ ⦙ apply:
   ⦙ ⦙ ⦙ ⦙ tags:
   ⦙ ⦙ ⦙ ⦙ ⦙ - clean-motd
   ⦙ ⦙ ⦙ ⦙ ⦙ - clean-all
   ⦙ ⦙ ⦙ ⦙ ⦙ - never
   ⦙ ⦙ tags:
   ⦙ ⦙ ⦙ - clean-motd
   ⦙ ⦙ ⦙ - clean-all
   ⦙ ⦙ ⦙ - never
   ⦙ - include_role:
   ⦙ ⦙ ⦙ name: sysctl
   ⦙ ⦙ ⦙ apply:
   ⦙ ⦙ ⦙ ⦙ tags:
   ⦙ ⦙ ⦙ ⦙ ⦙ - sysctl
   ⦙ ⦙ tags:
   ⦙ ⦙ ⦙ - sysctl
(LOTS of other include_role stanzas defining roles that are on all machines)

- name: apply configuration for bind9 servers
   hosts:
   ⦙ - alemana
   ⦙ - cadencia
   ⦙ - gancho
   ⦙ - impetus
   ⦙ - lasso
   ⦙ - torres
   ⦙ - dns1
   remote_user: zgansible
   become: "yes"
   vars:
   ⦙ bind_role: "{{ (bind|default({}))|combine(bind_group|default({}), 
recursive=true, list_merge='append') }}"
   tasks:
   ⦙ - include_role:
   ⦙ ⦙ ⦙ name: bind9
   ⦙ ⦙ ⦙ apply:
   ⦙ ⦙ ⦙ ⦙ tags:
   ⦙ ⦙ ⦙ ⦙ ⦙ - bind9
   ⦙ ⦙ tags:
   ⦙ ⦙ ⦙ - bind9

- name: apply configuration for DHCP servers
   hosts:
   ⦙ - chasse
   ⦙ - cadencia
   remote_user: zgansible
   become: "yes"
   tasks:
   ⦙ - include_role:
   ⦙ ⦙ ⦙ name: isc-dhcp-server
   ⦙ ⦙ ⦙ apply:
   ⦙ ⦙ ⦙ ⦙ tags:
   ⦙ ⦙ ⦙ ⦙ ⦙ - isc-dhcp-server
   ⦙ ⦙ tags:
   ⦙ ⦙ ⦙ - isc-dhcp-server

Is this the way to do it? Any comments will be appreciated.

In the other news, where would I correctly place (and activate) this handler:

---
- name: apt update
   command: "apt-get update"

if I intend to notify this handler from any role that might use the apt
provider to install packages?

Thank you in advance!

Greetings
Marc




--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b4b9b565-4a21-74f4-2874-ffaeab056549%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Playbook structure

2022-05-12 Thread Marc Haber
Hi Dirk,

On Tue, May 10, 2022 at 08:30:13AM +0200, Dick Visser wrote:
> On 2022-05-09 (Mon) 22:06, Marc Haber wrote:
> > after using ansible for quite a while, my project to manage my own
> > servers has grown to a respectable size. I was a puppet user before, so
> > I have a single big playbook containing everything. I have the feeling
> > this is like holding ansible wrong, and I also have the feeling that I
> > have my playbook structured wrong. Judging from the single "name"
> > setting, I took the wrong turn in the very beginning. The playbook does
> > what it is intended to do, however.
> > 
> > Here is an excerpt from my playbook.
> > 
> > ---
> > - name: apply common configuration
> >   hosts: all
> >   remote_user: zgansible
> >   become: "yes"
> 
> What is the reason for quoting this boolean? It is usually done to force it
> to be a string, but AFAIK this parameter requires a boolean.

Historical reasons, fixed. I probably didnt know any better, and it's
still a matter of try-and-err whether to find out whether ansible
wants/insists on things being quoted or not.

[snip]

> I don't see anything totally wrong with the above approach.
> Perhaps try to avoid the inline lists but that's cosmetics.

How would I write them any better?

> > In the other news, where would I correctly place (and activate) this 
> > handler:
> > 
> > ---
> > - name: apt update
> >command: "apt-get update"
> > 
> > if I intend to notify this handler from any role that might use the apt
> > provider to install packages?
> 
> What is the use case for this?
> If you want to make sure this is always run prior to any package task, then
> you should use the update_cache parameters of the apt module:
> 
> https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html#parameter-update_cache

updating the package lists after fiddling with things in /etc/apt, for
example preparing a release upgrade or adding an external repository
(docker *cough*). Doing an apt update right before any check whether any
required package is already installed seems overkill, but I need to
ponder about that.

Greetings
Marc

-- 
-
Marc Haber | "I don't trust Computers. They | Mailadresse im Header
Leimen, Germany|  lose things."Winona Ryder | Fon: *49 6224 1600402
Nordisch by Nature |  How to make an American Quilt | Fax: *49 6224 1600421

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/YnzoGApWeyrosE3G%40torres.zugschlus.de.