User Tools

Site Tools


ansible:ansible_os_deployment

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
ansible:ansible_os_deployment [2025/04/22 22:38]
manu [Conditional role]
ansible:ansible_os_deployment [2025/06/02 17:51] (current)
manu [Create filesystems]
Line 80: Line 80:
 </​cli>​ </​cli>​
  
-Also facts:  +Also useful ​facts: ​ 
-  ​AIX+ 
 +=== AIX === 
 +  ​"​ansible_os_family":​ "AIX",
   "​ansible_distribution":​ "​AIX",​   "​ansible_distribution":​ "​AIX",​
   "​ansible_distribution_major_version":​ "​7",​   "​ansible_distribution_major_version":​ "​7",​
Line 87: Line 89:
   "​ansible_distribution_version":​ "​7.2",​   "​ansible_distribution_version":​ "​7.2",​
   "​ansible_architecture":​ "​chrp",​   "​ansible_architecture":​ "​chrp",​
-  ​Linux+  ​"​ansible_system":​ "​AIX"​ 
 +   
 +=== Linux === 
 +  "​ansible_os_family":​ "​RedHat",​
   "​ansible_distribution":​ "​openSUSE Leap",   "​ansible_distribution":​ "​openSUSE Leap",
   "​ansible_distribution_file_variety":​ "​SUSE",​   "​ansible_distribution_file_variety":​ "​SUSE",​
Line 94: Line 99:
   "​ansible_distribution_version":​ "​15.1",​   "​ansible_distribution_version":​ "​15.1",​
   "​ansible_architecture":​ "​x86_64",​   "​ansible_architecture":​ "​x86_64",​
 +  "​ansible_system":​ "​Linux"​
 +or "​ansible_architecture":​ "​ppc64le",​
 ===== Pre task for AIX to set ansible_python_interpreter ===== ===== Pre task for AIX to set ansible_python_interpreter =====
  
Line 145: Line 152:
     "​mount_point":​ "/​data",​     "​mount_point":​ "/​data",​
     "​size":​ "​2G"​     "​size":​ "​2G"​
 +    "​type":​ "​jfs2"​
   },   },
   {   {
Line 151: Line 159:
     "​mount_point":​ "/​app",​     "​mount_point":​ "/​app",​
     "​size":​ "​5G"​     "​size":​ "​5G"​
 +    "​type":​ "​jfs2"​
   }   }
 ] ]
Line 169: Line 178:
     - name: Create logical volume     - name: Create logical volume
       ansible.builtin.shell:​ |       ansible.builtin.shell:​ |
-        mklv -t jfs2 -y {{ item.lvname }} {{ item.vgname }} {{ item.size }}+        mklv -t {{ item.type }} -y {{ item.lvname }} {{ item.vgname }} {{ item.size }}
       args:       args:
         creates: "/​dev/​{{ item.lvname }}"         creates: "/​dev/​{{ item.lvname }}"
Line 176: Line 185:
     - name: Create file system     - name: Create file system
       ansible.builtin.shell:​ |       ansible.builtin.shell:​ |
-        crfs -v jfs2 -d {{ item.lvname }} -m {{ item.mount_point }} -A yes+        crfs -v {{ item.type }} -d {{ item.lvname }} -m {{ item.mount_point }} -A yes
       args:       args:
         creates: "{{ item.mount_point }}"         creates: "{{ item.mount_point }}"
Line 249: Line 258:
   You could replace size parsing with something like:   You could replace size parsing with something like:
   lsfs /data | awk '​NR>​1 {printf "​%.0fG\n",​ $3*512/​1024/​1024/​1024}'​   lsfs /data | awk '​NR>​1 {printf "​%.0fG\n",​ $3*512/​1024/​1024/​1024}'​
 +
 +
 +===== Playbook2 =====
 +
 +<cli prompt='​$'>​
 +[ansible@lnx001 playbooks]$ cat main.yml
 +---
 +- name: Master playbook
 +  hosts: all
 +  gather_facts:​ true
 +  become: yes
 +  roles:
 +    - role: aix_system_config
 +      when:
 +        - ansible_system == "​AIX"​
 +    - role: lnx_system_config
 +      when:
 +        - ansible_system == "​Linux"​
 +
 +[ansible@lnx001 playbooks]$ cat roles/​lnx_system_config/​tasks/​main.yml
 +---
 +- name: Include SSH configuration tasks
 +  include_tasks:​ ssh_config.yml
 +
 +[ansible@lnx001 playbooks]$ cat roles/​lnx_system_config/​vars/​main.yml
 +---
 +_etc_ssh_sshd_config:​ /​etc/​ssh/​sshd_config
 +
 +[ansible@lnx001 playbooks]$ cat roles/​lnx_system_config/​files/​sshd_config.json
 +[
 +  {
 +    "​name":​ "​Port",​
 +    "​line":​ "Port 22",
 +    "​action":​ "​replace"​
 +  },
 +  {
 +    "​name":​ "​ListenAddress",​
 +    "​line":​ "​ListenAddress 0.0.0.0",​
 +    "​action":​ "​replace"​
 +  },
 +  {
 +    "​name":​ "​ListenAddress",​
 +    "​line":​ "​ListenAddress ::",
 +    "​action":​ "​remove"​
 +  },
 +  {
 +    "​name":​ "​UseDNS",​
 +    "​line":​ "​UseDNS no",
 +    "​action":​ "​replace"​
 +  },
 +  {
 +    "​name":​ "​SyslogFacility",​
 +    "​line":​ "​SyslogFacility AUTH",
 +    "​action":​ "​replace"​
 +  },
 +  {
 +    "​name":​ "​LogLevel",​
 +    "​line":​ "​LogLevel INFO",
 +    "​action":​ "​replace"​
 +  },
 +  {
 +    "​name":​ "​PermitRootLogin",​
 +    "​line":​ "​PermitRootLogin yes",
 +    "​action":​ "​replace"​
 +  },
 +  {
 +    "​name":​ "​PasswordAuthentication",​
 +    "​line":​ "​PasswordAuthentication yes",
 +    "​action":​ "​replace"​
 +  },
 +  {
 +    "​name":​ "​UsePAM",​
 +    "​line":​ "​UsePAM yes",
 +    "​action":​ "​replace"​
 +  },
 +  {
 +    "​name":​ "​PidFile",​
 +    "​line":​ "​PidFile /​var/​run/​sshd.pid",​
 +    "​action":​ "​replace"​
 +  },
 +  {
 +    "​name":​ "​Subsystem",​
 +    "​line":​ "​Subsystem sftp /​usr/​libexec/​openssh/​sftp-server -f AUTH -l INFO",
 +    "​action":​ "​replace"​
 +  },
 +  {
 +    "​name":​ "​KexAlgorithms",​
 +    "​line":​ "​KexAlgorithms -*sha1*",​
 +    "​action":​ "​insertafter",​
 +    "​after":​ "​GSSAPIEnablek5users"​
 +  },
 +  {
 +    "​name":​ "​MACs",​
 +    "​line":​ "MACs -*umac-64*,​*sha1*,​umac-128-etm@openssh.com",​
 +    "​action":​ "​insertafter",​
 +    "​after":​ "​GSSAPIEnablek5users"​
 +  }
 +]
 +
 +</​cli>​
ansible/ansible_os_deployment.1745354313.txt.gz · Last modified: 2025/04/22 22:38 by manu