Re: [ansible-project] Install raid1 and bios on a HP ilo server

2020-08-29 Thread Igor Gnatenko
I think this is the wrong question to ask. Depending on what you want
to configure in iLO, you could simply use the `uri` module to interact
with the redfish API. If you need to set up some BIOS parameters, your
best friend would be `hponcfg` from some OS (possibly during the
installation of OS). Same goes for RAID, I don't think you can easily
create it without having some OS, in our company we build our own
images with `ssacli` and create RAID as a part of %pre section of
kickstart file (we use CentOS).

On Sat, Aug 29, 2020 at 3:01 AM devo...@gmail.com  wrote:
>
> Hi,
>
> Need to install and configure raid1 and bios on a HP ilo server (before OS 
> installation) by ansible playbook. Can we install raid1 and bios by CLI on a 
> HP ILO (has to done by ansible playbook), if yes can you please give me a 
> reference.
>
> Thanks in advance.
>
> --
> 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/77ab9b14-994e-4750-a9d5-68e27a6dc714n%40googlegroups.com.



-- 
-Igor Gnatenko

-- 
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/CAFMg4WCXK8SN69o6JNKqK9ftMbkmwpt_mtYFrq7pxEVU9W5-Ag%40mail.gmail.com.


[ansible-project] Re: Trying to Store set fact variable based on when condtion

2020-08-29 Thread Praveen Kumar
Note: Security reasons i have replaced instance Id's with names.
On Saturday, August 29, 2020 at 4:36:45 PM UTC+5:30 Praveen Kumar wrote:

> Hi,
>
> Am writing a logic to get the list of servers running more than n number 
> of day's. I tried to store the result in a set_fact variable but it's not 
> storing the values properly mean it including the skipped values in the 
> set_facts. How to fix this?
>
> - name: Compare the times
>   set_fact:
> temp: "{{ ec2.instances  | map(attribute='instance_id') | list  }}"
>   when: ((ansible_date_time.iso8601[:19] | to_datetime(fmt) - 
> item.launch_time[:19] | to_datetime(fmt)).days >= 1)
>   with_items: "{{ ec2.instances }}"
>   vars:
> fmt: "%Y-%m-%dT%H:%M:%S"
>   register: timestamp1
>   loop_control:
> label: "{{ item.instance_id }}"
>
> Below is the ouput:
>
> `TASK [Compare the times] 
> *
> skipping: [localhost] => (item=Prod-scoring-ami-machine)
> ok: [localhost] => (item=stage-scoring-202007241050087142)
> ok: [localhost] => (item=stage-scoring-202007241051329817)
> ok: [localhost] => (item=stage-scoring-202007241129464655)
> ok: [localhost] => (item=stage-scoring-202007241123295962)
> ok: [localhost] => (item=stage-scoring-202008261826362494)
> skipping: [localhost] => (item=prod-scoring-202008282138514763)
> skipping: [localhost] => (item=prod-scoring-202008282300303548)
>
> TASK [Debug the output] 
> **
> ok: [localhost] => {
> "msg": [
> "Prod-scoring-ami-machine",
> "stage-scoring-202007241050087142",
> "stage-scoring-202007241051329817",
> "stage-scoring-202007241129464655",
> "stage-scoring-202007241123295962",
> "stage-scoring-202008261826362494",
> "prod-scoring-202008282138514763",
> "prod-scoring-202008282300303548"
> ]
> }
>
> Expected output:
>
> TASK [Compare the times] 
> *
> skipping: [localhost] => (item=Prod-scoring-ami-machine)
> ok: [localhost] => (item=stage-scoring-202007241050087142)
> ok: [localhost] => (item=stage-scoring-202007241051329817)
> ok: [localhost] => (item=stage-scoring-202007241129464655)
> ok: [localhost] => (item=stage-scoring-202007241123295962)
> ok: [localhost] => (item=stage-scoring-202008261826362494)
> skipping: [localhost] => (item=prod-scoring-202008282138514763)
> skipping: [localhost] => (item=prod-scoring-202008282300303548)
>
> TASK [Debug the output] 
> **
> ok: [localhost] => {
> "msg": [
> "stage-scoring-202007241050087142",
> "stage-scoring-202007241051329817",
> "stage-scoring-202007241129464655",
> "stage-scoring-202007241123295962",
> "stage-scoring-202008261826362494",
> ]
> }
>
>
> The above code returns all the values rather than condition met values. i 
> mean it includes the skipped values. How to get only matched or task is ok 
> values.
>
> Any ideas much appreciated.
>
>
> Thanks !
>
>
>

-- 
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/509ef407-652e-499e-a1dc-9fb58bd14a92n%40googlegroups.com.


[ansible-project] Trying to Store set fact variable based on when condtion

2020-08-29 Thread Praveen Kumar
Hi,

Am writing a logic to get the list of servers running more than n number of 
day's. I tried to store the result in a set_fact variable but it's not 
storing the values properly mean it including the skipped values in the 
set_facts. How to fix this?

- name: Compare the times
  set_fact:
temp: "{{ ec2.instances  | map(attribute='instance_id') | list  }}"
  when: ((ansible_date_time.iso8601[:19] | to_datetime(fmt) - 
item.launch_time[:19] | to_datetime(fmt)).days >= 1)
  with_items: "{{ ec2.instances }}"
  vars:
fmt: "%Y-%m-%dT%H:%M:%S"
  register: timestamp1
  loop_control:
label: "{{ item.instance_id }}"

Below is the ouput:

`TASK [Compare the times] 
*
skipping: [localhost] => (item=Prod-scoring-ami-machine)
ok: [localhost] => (item=stage-scoring-202007241050087142)
ok: [localhost] => (item=stage-scoring-202007241051329817)
ok: [localhost] => (item=stage-scoring-202007241129464655)
ok: [localhost] => (item=stage-scoring-202007241123295962)
ok: [localhost] => (item=stage-scoring-202008261826362494)
skipping: [localhost] => (item=prod-scoring-202008282138514763)
skipping: [localhost] => (item=prod-scoring-202008282300303548)

TASK [Debug the output] 
**
ok: [localhost] => {
"msg": [
"Prod-scoring-ami-machine",
"stage-scoring-202007241050087142",
"stage-scoring-202007241051329817",
"stage-scoring-202007241129464655",
"stage-scoring-202007241123295962",
"stage-scoring-202008261826362494",
"prod-scoring-202008282138514763",
"prod-scoring-202008282300303548"
]
}

Expected output:

TASK [Compare the times] 
*
skipping: [localhost] => (item=Prod-scoring-ami-machine)
ok: [localhost] => (item=stage-scoring-202007241050087142)
ok: [localhost] => (item=stage-scoring-202007241051329817)
ok: [localhost] => (item=stage-scoring-202007241129464655)
ok: [localhost] => (item=stage-scoring-202007241123295962)
ok: [localhost] => (item=stage-scoring-202008261826362494)
skipping: [localhost] => (item=prod-scoring-202008282138514763)
skipping: [localhost] => (item=prod-scoring-202008282300303548)

TASK [Debug the output] 
**
ok: [localhost] => {
"msg": [
"stage-scoring-202007241050087142",
"stage-scoring-202007241051329817",
"stage-scoring-202007241129464655",
"stage-scoring-202007241123295962",
"stage-scoring-202008261826362494",
]
}


The above code returns all the values rather than condition met values. i 
mean it includes the skipped values. How to get only matched or task is ok 
values.

Any ideas much appreciated.


Thanks !


-- 
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/c08ada28-d242-48ab-8313-0349b9233abfn%40googlegroups.com.


Re: [ansible-project] Trying to use pexpect ansible module to run interactive script

2020-08-29 Thread Sebastian Collins
OK, 

I see what I was doing the wrong. The last question of the interactive 
script was framed slightly differently and included an extra colon 
immediately after the word Port which I had omitted:

Postgresql Port: [default: 5432]:

Now I have added this colon to my final response, the pexpect module is 
working a treat.

Thanks very much for your help.


On Friday, August 28, 2020 at 3:36:30 PM UTC+1 Sebastian Collins wrote:

> Legend! I never would have figured this out, so thanking you kindly.
>
> I have hit one error after this:  : 
>
> "argument responses is of type  and we were unable to convert 
> to dict" 
>
> for which I have managed to nearly resolve it having found a solution to 
> which you again had provided to someone else:  : 
> https://groups.google.com/g/ansible-project/c/dDKvb1m5yM8
>
> I now have the ansible task formed liked this:
>
> - name: Setup postcodesiodb
>   expect:
> echo: yes
> chdir: "/apps/was/postcodes.io"
> command: npm run setup
> timeout: "10"
> responses: 
>
> 'Postgresql Superuser \(for database creation\) \[default: 
> postgres\]': 'postgres'
>
> 'New Database Username \(for readonly access\) \[default: 
> postcodesio\]': 'postcodesio'
> 'Password for new user \[default: secret\]': 'secret'
> 'Postgresql Host \[default: localhost\]': 'localhost'
> 'Database Name \[default: postcodesiodb\]': 'postcodesiodb'
> 'Postgresql Port \[default: 5432\]': 5432
>   tags:
> - setup
> - install
> - test   
>
>  The task is no longer producing that error and I can see the values being 
> populated with the exception the the final Port value which still does not 
> look to be parsing "5432" correctly. I have tried removing the single 
> quotes around it, to make it clear it is an integer as opposed to a string 
> but that has made no difference. I also can't see any discrepancies with 
> the escape characters used for regex  compared to the previous responses 
> which are now working. Any ideas what I need to do to close this off?
>
> FAILED! => {"changed": true, "cmd": "npm run setup",
> ...
> Apply read-only privileges for the new user to the new database", "", 
> "Postgresql Superuser (for database creation) [default: 
> postgres]:postgres", "New Database Username (for readonly access) [default: 
> postcodesio]:postcodesio", "Password for new user [default: 
> secret]:secret", "Postgresql Host [default: localhost]:localhost", 
> "Database Name [default: postcodesiodb]:postcodesiodb", "Postgresql Port: 
> [default: 5432]:"]}
>
>
> On Thursday, August 27, 2020 at 2:41:41 PM UTC+1 Matt Martz wrote:
>
>> There are a few problems with your task.
>>
>> 1. `Question` as used in the example, is supposed to represent the prompt 
>> or string to match. So you need to remove that.
>> 2. The "questions", prompts, or matches are regex, so you have to escape 
>> characters that have special meaning in regex
>>
>> responses:
>> 'Postgresql Superuser \(for database creation\) \[default: 
>> postgres\]': 'postgres'
>> 'New Database Username \(for readonly access\) \[default: 
>> postcodesio\]': 'postcodesio'
>> 'Password for new user \[default: secret\]': 'secret'
>> 'Postgresql Host \[default: localhost\]': 'localhost'
>> 'Database Name \[default: postcodesiodb\]': 'postcodesiodb'
>> 'Postgresql Port \[default: 5432\]': '5432'
>> On Thu, Aug 27, 2020 at 6:22 AM Sebastian Collins  
>> wrote:
>>
>>> Hi,
>>>
>>> I have composed this ansible task using the pexpect module to run a 
>>> setup.sh script with npm run
>>>
>>> - name: Setup postcodesiodb
>>>   expect:
>>> echo: yes
>>> chdir: "/apps/was/postcodes.io"
>>> command: npm run setup
>>> timeout: "10"
>>> responses:
>>>   Question: 
>>>
>>> - 'Postgresql Superuser (for database creation) [default: 
>>> postgres]': 'postgres'
>>>
>>> - 'New Database Username (for readonly access) [default: 
>>> postcodesio]': 'postcodesio'
>>> - 'Password for new user [default: secret]': 'secret'
>>> - 'Postgresql Host [default: localhost]': 'localhost'
>>> - 'Database Name [default: postcodesiodb]': 'postcodesiodb'
>>> - 'Postgresql Port [default: 5432]': '5432'
>>>   tags:
>>> - setup
>>> - install
>>> - test   
>>>
>>>
>>>
>>> Below is the only error logging I have but it's failed at the first 
>>> input I am attempting to populate here the postgres Super user. Any ideas 
>>> how I need to pass in these answers and or variables if I don't want to 
>>> hard code? Currently it just looks like it is picking up  "] characters.
>>>  
>>> Fatal: [hostname]: FAILED! => {"changed": true, "cmd": "npm run setup", 
>>> "delta": "0:02:00.145566", "end": "2020-08-25 21:33:22.107526", "msg": 
>>>