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

lp_netplan push comments to file #2

Open
do-d1 opened this issue Oct 10, 2024 · 1 comment
Open

lp_netplan push comments to file #2

do-d1 opened this issue Oct 10, 2024 · 1 comment

Comments

@do-d1
Copy link

do-d1 commented Oct 10, 2024

Hello

is there an option to add comments into netplan ?

i want my /etc/netplan/00-installer-config.yaml to look like:

#TO-WAN
    enp0s31f6:
     dhcp4: true
#     addresses: [10.42.0.1/24]
#     routes:
#      - to: default
#        via: 10.42.0.1
#     nameservers:
#       addresses: [8.8.8.8,8.8.4.4]

#ToRouter
    enp4s0:
     dhcp4: no
     addresses: [192.168.8.100/24]
#     routes:
#      - to: default
#        via: 192.168.8.1
#     nameservers:
#       addresses: [8.8.8.8,8.8.4.4]

#slot1
    enp5s0:
     dhcp4: no
     ignore-carrier: true
     addresses: [10.42.1.1/24]
#slot2
    enp6s0:
     dhcp4: no
     ignore-carrier: true
     addresses: [10.42.2.1/24]

how do i push the #slot2 for example? 
@vbotka
Copy link
Owner

vbotka commented Oct 10, 2024

There is no such option. However, the task is flexible

- name: "Netplan: Configure files in {{ lp_netplan_root }}"
  notify: netplan apply
  ansible.builtin.template:
    src: netplan-conf.j2
    dest: "{{ lp_netplan_root }}/{{ item.file }}"
    owner: "{{ item.owner | d(lp_netplan_owner) }}"
    group: "{{ item.group | d(lp_netplan_group) }}"
    mode: "{{ item.mode | d(lp_netplan_mode) }}"
    backup: "{{ lp_backup_conf }}"
  loop: "{{ lp_netplan_conf }}"
  loop_control:
    label: "{{ item.file }}"

You can create and use a template that will serve your use case. Fit the data too. For example,

lp_netplan_conf:
  - file: 00-installer-config.yaml 
    category: ethernets
    conf:
      enp0s31f6:
        dhcp4: true
        label: "#TO-WAN"
        comment: |
          #     addresses: [10.42.0.1/24]
          #     routes:
          #      - to: default
          #        via: 10.42.0.1
          #     nameservers:
          #       addresses: [8.8.8.8,8.8.4.4]
  ...

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

No branches or pull requests

2 participants