[pve-devel] [PATCH v1 installer 14/18] auto-installer: add fetch answer binary

Aaron Lauterer a.lauterer at proxmox.com
Fri Feb 16 17:34:17 CET 2024



On 2/8/24 17:46, Aaron Lauterer wrote:
> 
> 
> On 2/8/24 15:18, Christoph Heiss wrote:
>> Sorry for not including this in the first email.
>>
>> On Tue, Jan 23, 2024 at 06:00:49PM +0100, Aaron Lauterer wrote:
>> [..]
>>> diff --git a/proxmox-auto-installer/src/fetch_plugins/partition.rs b/proxmox-auto-installer/src/fetch_plugins/partition.rs
>>> new file mode 100644
>>> index 0000000..0552ddd
>>> --- /dev/null
>>> +++ b/proxmox-auto-installer/src/fetch_plugins/partition.rs
>>> @@ -0,0 +1,102 @@
>>> +use anyhow::{bail, Result};
>>> +use log::{info, warn};
>>> +use std::fs::read_to_string;
>>> +use std::path::{Path, PathBuf};
>>> +use std::process::Command;
>>> +
>>> +static ANSWER_FILE: &str = "answer.toml";
>>> +static ANSWER_MP: &str = "/mnt/answer";
>>> +static PARTLABEL: &str = "proxmoxinst";
>>> +static SEARCH_PATH: &str = "/dev/disk/by-label";
>>> +
>>> +pub struct FetchFromPartition;
>>> +
>>> +impl FetchFromPartition {
>>> +    /// Returns the contents of the answer file
>>> +    pub fn get_answer() -> Result<String> {
>>> +        let part_path = Self::scan_partlabels()?;
>>> +        Self::mount_part(part_path)?;
>>> +        Self::get_answer_file()
>>
>> Before returning, the partition should be unmounted, as it is not needed
>> anymore after this point.
>>
>> This also prevents some funny error that occurs if the installation
>> fails due to some error. The next time `proxmox-fetch-answer` is run, it
>> cannot mount the answer partition anymore, due to being already mounted.
> 
> For now sure. If we add additional plugins to fetch the answer file via a URL, we might want to place the ssl fingerprint on the same partition. Then we would have to either mount it again, or wait with the unmount until we have reached the end of going through the plugins, as a cleanup measure.

Actually, I think we want to keep it mounted. A warning when running the `proxmox-fetch-answer` once more, should be okay and will mainly happen during testing but not in a real-life scenario. It also makes it easy to place additional data on the partition and use it in a pre- or post-command. For example, scripts, config files, deb packages and so forth.




More information about the pve-devel mailing list